c# - Linq to Entity - How to concatenate conditions -
i writing linq query. there way can concatenate query based on if conditions?
like on query is
res in _db.person res.departments.id == deptid select res;
and if have condition true, like
from res in _db.person res.departments.id == deptid && res.departments.type == depttype select res;
assuming condition in variable condition
from res in _db.person res.departments.id == deptid && (!condition || res.departments.type == depttype) select res;
version or requested
from res in _db.person res.departments.id == deptid || (condition && res.departments.type == depttype)) select res;
alternatively may wish use predicate builder
Comments
Post a Comment