How can the foll. sql be written in Linq. I am using LinqToEntities,C#. @companyID & @branchID are the parameters
select * from tblEmp e
where e.deleted = 0 and
(e.companyId = @companyID OR e.companyid is null) and
(e.branchId = @branchID OR e.branchid is null)
For now, there is a stored procedure for the same and I am using it in linq, like this:
var qry = from d in MYDB.GetData(int companyid, int branchid)
select new
{
//all reqd. columns...
}
so, is it possible to write the above in Linq, directly.
EDIT:
public IEnumerable<tblEmp> GetData(Guid gCID, Guid gBID)
{
var employees = (from e in tblEmp
where !e.deleted
&& (e.companyId == gCID || e.companyid == null)
&& (e.branchId == gBID || e.branchid == null)
select e
).AsEnumerable();
}
//Both Parameters are '00000000-0000-0000-0000-000000000000'. I am expecting all records but the count is 0. Where am I going wrong.