Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to use multple value in one column and check with multpe option in linq

What I have tried:

C#
List<ProductViewModel> viewModel = model.pageViewModelList
         .Where(s =>
                     s.Size.Contains(SizeRecord)  &&
                     s.Color.Contains(("'Red', 'Pink'")))
         .ToList();
Posted
Updated 15-Aug-17 22:13pm
v2
Comments
Andy Lanng 16-Aug-17 4:14am    
I have no idea what you are asking. Please try to rephrase the question
Kornfeld Eliyahu Peter 16-Aug-17 4:44am    
Not clear...
Do you mean a column that contains a list of color values (separated by what?) and you want to check that all values are valid color names?
Or do you mean that the column can have one value, picked from a list of color names (lookup table)?
vermanishad 16-Aug-17 6:00am    
like database have one column and the value (red,Purple) both are in one column, and i want to when i will hit a linq query for search filter then result want red wise red show and if i choose mutple option in html side then show as well as like in sql query show for (red,purple)
Richard Deeming 17-Aug-17 11:40am    
Stuffing multiple values into a single column is an extremely bad design, and the problems you're having querying the data perfectly illustrate why.

Put the valid values in their own table, and set up a many-to-many link between that table and the products. For example:
Colors:

ID   Color
----------
1    Red
2    Purple
...


ProductColors:

ProductID    ColorID
--------------------
1            1
1            2
...
vermanishad 18-Aug-17 2:13am    
Richard i was clearly mention my posting i want to check for multple option but you did not say my table layout not valid coz i have a one column for multple value i know wht you said i know it correct but i want this way for my query offcourse i was done myself to another way for same problem and i am fetching record exectly what i want on same like column under multple option so thank for your sugestion i was resolve my self

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