0
我使用具有Get方法一GenericRepository:在EF中使用Take擴展方法的內存中有多少個對象?
我想知道是否有代碼以下塊之間的負載差異:
Expression<Func<PressRelease_ar, bool>> exp = p => p.Id <=5 ;
lst = Global.uow.PressReleaseRepository_ar
.Get
(
filter : exp,
orderBy: n => n.OrderByDescending(d => d.Id)
).ToList();
而且
lst = Global.uow.PressReleaseRepository_ar
.Get
(
orderBy: n => n.OrderByDescending(d => d.Id)
).Take(5).ToList();
更多詳細信息,這是Get方法:
public virtual IEnumerable<TEntity> Get(
Expression<Func<TEntity, bool>> filter = null,
Func<IQueryable<TEntity>,
IOrderedQueryable<TEntity>> orderBy = null,
string includeProperties = "")
{
IQueryable<TEntity> query = dbSet;
if (filter != null) query = query.Where(filter);
foreach (var includeProperty in includeProperties.Split
(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{
query = query.Include(includeProperty);
}
if (orderBy != null) return orderBy(query).ToList();
else return query.ToList();
}
你的Get方法中有語法錯誤。 – Alxandr
你的問題題目很混亂。急切和懶惰加載指的是加載實體的*導航屬性*的不同方法。你的問題與加載導航屬性無關,是嗎? – Slauma
@Slauma:請給出建議標題。感謝您的回答,滿意。 – Samidjo