I am using C # 3.5. I have IList<MyItemLinkProperty> , where MyItemLinkProperty represents the link between an element and its properties (one or more). It has ItemId , PropertyId , PropertyValue . In this list, ItemId can occur many times, since an item can have many properties, color, size, etc. (This is a performance issue that I have such a list and is not tied to an element object).
ItemID PropId PropValue itemProperty1 = { 1001, 1, 'Red' } itemProperty2 = { 1001, 2, 'Small' } itemProperty3 = { 1002, 1, 'Red' } itemProperty4 = { 1002, 3, 'Medium' } itemProperty5 = { 1003, 4, 'Green' } itemProperty6 = { 1003, 2, 'Small' }
Now I need to find all the elements that have property A and property B. For example, "red" and "small". This should give me ItemId 1001, which has both of these properties.
In the pseudocode, I think that after "give me the elements where the property id is 1 or 2 and the element identifier is the same." Then I know the items that have both of these properties.
I think the linq query will do this. But it didnβt work out so that it worked and got stuck. Maybe I'm blocking my mind here, thinking about it and making it too complicated ...
Any tips for a better solution?
source share