Click here to Skip to main content
16,018,006 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

I have a following Code:

C#
var db=new LINQDataContext();
grid.datasource=db.table.where(c=>c.field1=="Value1" && c.field2=="Value2")

I need to add or remove conditions to where,
how can i pass them by parameters?like Where SQL statements that
we can define a string to pass conditions.
Posted
Updated 1-Jan-12 19:23pm
v2

1 solution

This is in your C# code. So what you could do would be something like -
C#
var db=new LINQDataContext();
grid.datasource=db.table.where(c=>c.field1==""" + str2 + """ && c.field2==""" + str2 + """;)

where str1 and str2 would be variables that would act like your parameters.
 
Share this answer
 
Comments
Hekmat90 2-Jan-12 1:39am    
i need to add a parameter that contain &&/||
add a new third parameter or remove second parameter
for example each parameter active by checkbox when i select it active parameter or deactive.

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