Entity Framework اسئلة واجوبة المقابلات
سؤال 36. What is the purpose of the Remove method in Entity Framework?
The Remove method is used to mark an entity as Deleted in the context, and the entity will be deleted from the database when SaveChanges is called.
Example:
context.Entities.Remove(entityToDelete);
سؤال 37. Explain the purpose of the State property in Entity Framework.
The State property of EntityEntry is used to get or set the state of an entity being tracked by the context, such as Added, Modified, or Deleted.
Example:
entry.State = EntityState.Modified;
سؤال 38. What is the purpose of the FromSqlRaw method in Entity Framework?
The FromSqlRaw method is used to create a query based on raw SQL and map the result to entities. It is often used for executing stored procedures.
Example:
var result = context.Entities.FromSqlRaw("EXEC dbo.GetEntities");
سؤال 39. Explain the purpose of the AsQueryable method in Entity Framework.
The AsQueryable method is used to convert an IEnumerable Example:
سؤال 40. What is the purpose of the Set method in Entity Framework?
The Set method is used to get a DbSet for a given entity type, allowing you to perform database operations on that entity type.
Example:
var set = context.Set();
الاكثر فائدة حسب تقييم المستخدمين: