Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I use list in where clues in Entity Framework that list contain my searching value.

List<String> Search_option= new List<string>();
Search_option.add("a");
Search_option.add("b");

var Data= from a in Db_table select a;


And I also use this code too:

var Data= from a in Db_table where(Search_option.contains(a.Field.Tostring())) select a;


Thanks
Posted
Updated 8-Feb-12 5:49am
v3
Comments
BobJanova 8-Feb-12 11:24am    
What's the question? Does your second code sample not work?

you can use LINQ for searching in a LIST<> object
like
Search_option.Any(x => x.value == "a")
 
Share this answer
 
I Suggest you can use DropdownList for your Parameters

markup in line
-----------
ASP.NET
<asp:dropdownlist id="ddlSearchOption" runat="server">
 <asp:listitem text="-- Select One --" value="" selected="True"></asp:listitem>
 <asp:listitem text="A" value="A"></asp:listitem>
 <asp:listitem text="B" value="B"></asp:listitem>
</asp:dropdownlist>



Code Behind
-----------
C#
var Data = from a in Db_table
           where a.fieldName == this.ddlSearchOption.SelectedValue
           select a;

HTML
Other Option

C#
var Data = Db_table.Where(a => a.fieldName.Contains(this.ddlSearchOption.SelectedValue).ToList();


Hope this will help you
don't forget to vote
thanks
 
Share this answer
 
v3

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