||Added entity type
||Adds the given entity to the context the Added state. When the changes are being saved, the entities in the Added states are inserted into the database. After the changes are saved, the object state changes to Unchanged.
||Returns a new query where the entities returned will not be cached in the DbContext. (Inherited from DbQuery.)
Entities returned as AsNoTracking, will not be tracked by DBContext. This will be significant performance boost for read only entities.
|var studentList = dbcontext.Students.AsNoTracking<Student>().ToList<Student>();
||Entity which was passed as parameter
||Attaches the given entity to the context in the Unchanged state
||Creates a new instance of an entity for the type of this set. This instance is not added or attached to the set. The instance returned will be a proxy if the underlying context is configured to create proxies and the entity type meets the requirements for creating a proxy.
||Var newStudentEntity = dbcontext.Students.Create();
||Uses the primary key value to attempt to find an entity tracked by the context. If the entity is not in the context then a query will be executed and evaluated against the data in the data source, and null is returned if the entity is not found in the context or in the data source. Note that the Find also returns entities that have been added to the context but have not yet been saved to the database.
||//Find student whose StudentID is 1
Student studEntity = dbcontext.Students.Find(1);
||Returns the included non generic LINQ to Entities query against a DbContext. (Inherited from DbQuery)
||var studentList = dbcontext.Students.Include("StudentAddress").ToList<Student>();
var studentList = dbcontext.Students.Include(s => s.StudentAddress).ToList<Student>();
||Marks the given entity as Deleted. When the changes are saved, the entity is deleted from the database. The entity must exist in the context in some other state before this method is called.
||Creates a raw SQL query that will return entities in this set. By default, the entities returned are tracked by the context; this can be changed by calling AsNoTracking on theDbSqlQuery<TEntity> returned from this method.
||var studentEntity = dbcontext.Students.SqlQuery("select * from student where studentid = 1").FirstOrDefault<Student>()