Build dynamic LINQ?
- by d daly
Hi
Im using #LINQ# to query data,
but can anyone tell me how to build the query dynamically, if the user only wants to report on say 1 of the 3 fields? (see below)
Thanks
DD
var query = from cl in db.tblClaims
join cs in db.tblCases
on cl.ref_no equals cs.ref_no
where
cl.claim_status == "Appeal"
&& cl.appeal_date >= Convert.ToDateTime(txtReferedFromDate.Text)
&& cl.appeal_date <= Convert.ToDateTime(txtReferedToDate.Text)
&& cs.referred_from_lho == dlLHO.Text
&& cs.adviser == dlAdviser.Text
select new
{
Ref = cs.ref_no,
ClaimType = cl.claim_type,
ClaimStatus = cl.claim_status,
AppealDate = cl.appeal_date
};
gvReport.DataSource = query;