Answer the question
In order to leave comments, you need to log in
How to use the Include and AsNoTracking methods using the Repository pattern?
My current repository looks something like this:
class UserRepository : IRepository<User> // User - сущность entity
{
// контекст подключения к базе данных. Инициализируется в конструкторе
private readonly EntityContext _ctx;
public IQueryable<User> GetAll(){
return _ctx.User;
}
// ещё методы Save (INSERT), Update, Delete,
// но сейчас разбираем только выборку
// ...
}
Answer the question
In order to leave comments, you need to log in
I recently started learning about the structure of nopcommerce . There it is implemented as follows :
/// <summary>
/// Gets a table
/// </summary>
public virtual IQueryable<T> Table
{
get
{
return this.Entities;
}
}
/// <summary>
/// Gets a table with "no tracking" enabled (EF feature) Use it only when you load record(s) only for read-only operations
/// </summary>
public virtual IQueryable<T> TableNoTracking
{
get
{
return this.Entities.AsNoTracking();
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question