samba siva

samba siva

  • 1.4k
  • 322
  • 47.2k

Generic parameter for Linq where clause

Jan 23 2018 11:07 AM
I have the code like below:
 string x="Hyderabad";
var result=(from pr in db.Properties
join slp in ShortListProp on pr.PropertyId equals slp.PropertyId into gj
from dta in gj.DefaultIfEmpty()
where pr.City == x
select pr)
 
I want to pass pr.city==x dynamically.
string x="Hyderabad"; 
var query=pr.city==x;
 
var result=(from pr in db.Properties
join slp in ShortListProp on pr.PropertyId equals slp.PropertyId into gj
from dta in gj.DefaultIfEmpty()
where (query)
select pr)

Answers (5)