In this article, we will discuss:
Retrieving Specific Item
Retrieving List of Items
Adding an Item
Updating an Item
Deleting an Item
using Navigation Properties.
We will reuse the entity model that we have created earlier. It is recommended to understand Entity framework Relationships and navigational properties here.

Retrieving Specific Item
Description:
- create the DbContext object and using this object, you can fetch the Employer by the given employerId function
- If we find an Employer object with this ID, we retrieve the Employees associated with it. Internally, Entity Framework is generating a SQL to fetch all the employees associated with this employerid and return all the records as a collection of Employee entities
Retrieving List of Items:
Description:
- create the DbContext object and using this object, you can fetch the Employer by the given employerId function.
- If you find an Employer object with this ID, you retrieve the Employees associated with it.Internally, Entity Framework is generating a SQL to fetch all the employees associated with this employerid and return all the records as a collection of Employee entities
Adding an Item
Description:
Updating an Item:
Description:
- Create DbContext Object
- Fetch the Employer by the given employerId
- Find the existing Employee by using the ID in the new Employee object
- If the Employee is found, Update Employee with new values
- Save the changes. Please note that it is very important to call save changes since otherwise there will be no modifications to the data.
Deleting an Item
Description:
- Create DbContext Object
- Fetch the Employer by the given employerId
- Find the existing Employee by using the ID in the new Employee object
- If the Employee is found, delete Employee
- Save the changes. Please note that it is very important to call save changes since otherwise there will be no modifications to the data.
Thanks for visiting !!
No comments:
Post a Comment