我找到了一些有趣的通用存储库,但我无法弄清楚该函数的作用:PerformInclusions(includeProperties, query);
调用 PerformInclusions,
public T Single(Expression<Func<T, bool>> where, string includeProperties)
{
try
{
IQueryable<T> query = IDbSet;
query = PerformInclusions(includeProperties, query);
return query.Single(where);
}
catch (InvalidOperationException ex)
{
return null;
}
}
执行包含
private static IQueryable<T> PerformInclusions(string includeProperties,
IQueryable<T> query)
{
if (includeProperties != null && includeProperties.Length > 0)
{
foreach (var includeProperty in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{
query = query.Include(includeProperty);
}
}
return query;
}
我可以使用没有第二个参数的单个函数。
Euser test = Adapter.EuserRepository.Single(u => u.EuserEmail.Equals(user.EuserEmail), "");
所以我有两个问题,函数 PerformInclusions() 做了什么,有人可以给我一个例子,在调用 single() 函数时 includeproperties 是什么。
提前致谢