Click here to Skip to main content
15,913,133 members
Home / Discussions / C#
   

C#

 
QuestionLinq - Conditions for two categories in parallel Pin
Ronenb21-Aug-12 1:18
Ronenb21-Aug-12 1:18 
XML
Hi
I’ve a question regarding linq,
I’ve a DB contains main items (Product) and internal item(properties)

Class Product
{
    String name
List<properties> propList { get; set; }
}

Class properties
{
    String name
String value
}

I would like to know if it possible to create a query that apply on two or more categories on the same internal item at one time
Such as, if the product is "car" and if the car year is 2012 and color is "Red" I would like to get this record

List< Product > DB;

I know the syntax below is wrong, but this is the idea I wish to do
Enumerable< Product > itemQuery = from item in DB where item.name=="car"
                                            where
                                            (
                                                from prop in item.propList
                                                where (prop.name.Equals("Color") && prop.value == "Red") && (prop.name.Equals("Year") && prop.value == "2012")
                                                select field
                                             ).Any()
                                            select item;

AnswerRe: Linq - Conditions for two categories in parallel Pin
Wayne Gaylard21-Aug-12 3:21
professionalWayne Gaylard21-Aug-12 3:21 
AnswerMessage Removed Pin
21-Aug-12 3:40
professionalN_tro_P21-Aug-12 3:40 
GeneralRe: Linq - Conditions for two categories in parallel Pin
Ronenb22-Aug-12 20:54
Ronenb22-Aug-12 20:54 
GeneralRe: Linq - Conditions for two categories in parallel Pin
Ronenb26-Aug-12 21:59
Ronenb26-Aug-12 21:59 
GeneralMessage Removed Pin
27-Aug-12 2:41
professionalN_tro_P27-Aug-12 2:41 
GeneralRe: Linq - Conditions for two categories in parallel Pin
Ronenb27-Aug-12 5:46
Ronenb27-Aug-12 5:46 
GeneralDynamic Keyword Pin
gopesh201020-Aug-12 23:12
gopesh201020-Aug-12 23:12 
GeneralRe: Dynamic Keyword Pin
Pete O'Hanlon20-Aug-12 23:35
mvePete O'Hanlon20-Aug-12 23:35 
QuestionSame entries in Listbox from WCF Pin
coem20-Aug-12 22:19
coem20-Aug-12 22:19 
AnswerRe: Same entries in Listbox from WCF Pin
coem21-Aug-12 0:14
coem21-Aug-12 0:14 
QuestionEPPLUS excel percent format Pin
Member 916988720-Aug-12 20:10
Member 916988720-Aug-12 20:10 
QuestionRe: EPPLUS excel percent format Pin
Richard MacCutchan20-Aug-12 21:29
mveRichard MacCutchan20-Aug-12 21:29 
AnswerRe: EPPLUS excel percent format Pin
Member 916988721-Aug-12 14:06
Member 916988721-Aug-12 14:06 
AnswerRe: EPPLUS excel percent format Pin
Jay Nardev21-Aug-12 20:44
Jay Nardev21-Aug-12 20:44 
QuestionWait until user finish typing Pin
biop.codeproject20-Aug-12 17:59
biop.codeproject20-Aug-12 17:59 
AnswerRe: Wait until user finish typing Pin
AmitGajjar20-Aug-12 18:39
professionalAmitGajjar20-Aug-12 18:39 
AnswerRe: Wait until user finish typing Pin
Paul Conrad20-Aug-12 19:32
professionalPaul Conrad20-Aug-12 19:32 
AnswerRe: Wait until user finish typing Pin
Shameel20-Aug-12 20:12
professionalShameel20-Aug-12 20:12 
AnswerRe: Wait until user finish typing Pin
jschell21-Aug-12 8:30
jschell21-Aug-12 8:30 
AnswerRe: Wait until user finish typing Pin
Pete O'Hanlon21-Aug-12 9:10
mvePete O'Hanlon21-Aug-12 9:10 
AnswerRe: Wait until user finish typing Pin
biop.codeproject22-Aug-12 23:27
biop.codeproject22-Aug-12 23:27 
QuestionC# accessing a web service Pin
classy_dog20-Aug-12 15:16
classy_dog20-Aug-12 15:16 
AnswerRe: C# accessing a web service Pin
AspDotNetDev20-Aug-12 16:03
protectorAspDotNetDev20-Aug-12 16:03 
GeneralRe: C# accessing a web service Pin
classy_dog21-Aug-12 17:44
classy_dog21-Aug-12 17:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.