asp.net dynamic linq query
-
hi Dim job = From J In QryGen.co_jobs Where J.co_id = 1013 And J.industry_mas_id = 5 Order By J.job_id Descending Select New With {J.job_id} this my query. in this I would like construct the query on runtime for where condition. sometime need to include some other fields to where condition. I need help. Thanks in advance.
Have A Nice Day! Murali.M Blog
-
hi Dim job = From J In QryGen.co_jobs Where J.co_id = 1013 And J.industry_mas_id = 5 Order By J.job_id Descending Select New With {J.job_id} this my query. in this I would like construct the query on runtime for where condition. sometime need to include some other fields to where condition. I need help. Thanks in advance.
Have A Nice Day! Murali.M Blog
Try chaining the
Where
clauses:Dim query As IQueryable(Of Job) = QryGen.co_jobs
If filterById Then
query = From J in query Where J.co_id = 1013 Select J
End IfIf filterByIndustry Then
query = From J in query Where J.industry_mas_id = 5 Select J
End IfDim job As IQueryable(Of Job) = From J in query Order By J.job_id Descending Select New With { J.job_id }
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer