I am trying to use the answer from LINQ to SQL Where Clause Optional Criteria
I like my linq to use query based syntax. Not sure how to use the whereif.
my query will look something like this
var result = (from tran in _ctx.Transactions where tran.Id == transactionId select tran);
and sometimes projecting it
var result = (from tran in _ctx.Transactions where tran.Id == transactionId
select new Abstract
{
tran.Date,
tran.Key
});
I can do an optional filter using method syntax
var result = _ctx.Transactions
.where(t=>t.Id == transactionId)
.whereIf(tran.Dept!= "AllDept", x => x.Dept== deptName);
Not sure how to use the WhereIf in a query based linq query.