Build dynamic LINQ?
Posted
by d daly
on Stack Overflow
See other posts from Stack Overflow
or by d daly
Published on 2010-03-22T15:22:27Z
Indexed on
2010/03/22
15:31 UTC
Read the original article
Hit count: 333
LINQ
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;
© Stack Overflow or respective owner