当需要把context的where条件作为参数的时候,
/// <summary>
/// 这样的where不能正常作为检索条件,执行后不会报错,但条件不会被使用,并且还会使后续添加的条件也无效。
/// </summary>
/// <param name="where"></param>
public void AttachWhere(Func<AuthorRole, bool> w)
{
using (DealerAuthorityDataContext dataContext = new DealerAuthorityDataContext())
{
var result = dataContext.AuthorRole.Where(w);
}
}
/// <summary>
/// 这样的where才能正常作为检索条件
/// </summary>
/// <param name="where"></param>
public void AttachWhere(Expression<Func<AuthorRole, bool>> w)
{
using (DealerAuthorityDataContext dataContext = new DealerAuthorityDataContext())
{
var result = dataContext.AuthorRole.Where(w);
}
}
/// 这样的where不能正常作为检索条件,执行后不会报错,但条件不会被使用,并且还会使后续添加的条件也无效。
/// </summary>
/// <param name="where"></param>
public void AttachWhere(Func<AuthorRole, bool> w)
{
using (DealerAuthorityDataContext dataContext = new DealerAuthorityDataContext())
{
var result = dataContext.AuthorRole.Where(w);
}
}
/// <summary>
/// 这样的where才能正常作为检索条件
/// </summary>
/// <param name="where"></param>
public void AttachWhere(Expression<Func<AuthorRole, bool>> w)
{
using (DealerAuthorityDataContext dataContext = new DealerAuthorityDataContext())
{
var result = dataContext.AuthorRole.Where(w);
}
}