我有这些帮助方法:
public static IQueryable<T> All<T>(this IUnitOfWork unitOfWork)
where T : class
{
return unitOfWork.Context.Set<T>();
}
public static T Find<T>(this IUnitOfWork unitOfWork, Func<T, bool> predicate)
where T : class
{
return unitOfWork.All<T>().FirstOrDefault(predicate);
}
Run Code Online (Sandbox Code Playgroud)
当我打电话给第二个这样的时候:
var payment = _unitOfWork.Find<ContactRow>
(p => p.PaymentAttemptRef == paymentAttemptRef
&& p.ContactType == type);
Run Code Online (Sandbox Code Playgroud)
我希望谓词成为查询的一部分!! 但问题是生成的选择是没有where子句并且拉回表中的所有行.
知道为什么会这样吗?第二种方法调用第一种方法,返回一个iqueryable,所以我认为不会这样做?