Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
C#
db.table.where(c=>c.field1==value)


I have a several criteria for filtering table and define each by checkbox
for example checkbox1 must enable field1=value, checkbox2 must enable
field2=value and so on.

How i send them as parameters to where()?

i can solve this for 3 criteria and 3 checkbox by if and case and
considering multiple status but when criteria and checkboxes is more than 3
need to more lines and where statements.

How can do this by one where statement via parameters?
Posted
Updated 1-Jan-12 21:02pm
v3

1 solution

If the logic varies in your where condition, one possibility could be that you create a new method for selecting the correct rows. In that method you return the row if it matches your conditions. For example, see: Writing Custom LINQ Extension Methods[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900