Kumar Bhimsen
How to Read, Add, Update and Delete record in Entity Framework ?
By Kumar Bhimsen in .NET on Dec 11 2015
  • Ravi Patel
    Dec, 2015 30

    check thishttp://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/implementing-basic-crud-functionality-with-the-entity-framework-in-asp-net-mvc-application

    • 0
  • Kumar Bhimsen
    Dec, 2015 11

    For performing the CURD operation in EF. We have to use an object of context class. Example: To Read data record : CustomerContext obj = new CustomerContext(); Foreach(Customer cust in obj.customer) { // Do your work here. } To add data record: we use AddObject method and savechange method to add record. CustomerContext obj = new CustomerContext(); Customer custObj= new Customer(); custObj.Name=”Bhimsen”; custObj.Email=”[email protected]”; custObj.Mobile=8010326915; custObj.Address=”New Delhi”; obj.customer.addobject(custObj); obj.savechanges(); To Update Record : CustomerContext obj = new CustomerContext(); Customer custObj= (Customer) obj.Customer.firstOrDefault(); custObj.Name=”Bhimsen”; obj.AcceptAllChanges(); To Delete Record: CustomerContext obj = new CustomerContext(); Customer custObj= (Customer) obj.Customer.FirstOrDefault(); Obj.DeleteObject(CustObj);

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS