这似乎将是很容易
VAR ORX = gg.Where(X => x.ProductAttributes.Any(PA => pa.AttributeId ==家));
返回GG当产品属性有家
值我需要它从一个数组返回,其中和GG拥有产品属性值 即
VAR ORX = gg.Where(X => x.ProductAttributes.Any(PA => pa.AttributeId在家庭,工作));
解决方案
怎么样......
的String []值=新的String [] {家庭,工作};
VAR ORX = gg.Where(X => x.ProductAttributes.Any(PA => values.Contains(pa.AttributeId));
甚至家庭,工作。载(pa.AttributeId)
应该工作,如果你的列表是可靠的,你的榜样。 (我决不意味着推荐这个除非你能保证AttributeId不会被任何清单的话的一个子......比如我)
This seems like it would be easy enough
var orx = gg.Where(x=>x.ProductAttributes.Any (pa =>pa.AttributeId == "home"));
returns gg when product attributes has a value of "home"
I need it to return where and gg has product attribute values from an array i.e.
var orx = gg.Where(x=>x.ProductAttributes.Any (pa =>pa.AttributeId in "home,work"));
解决方案
what about...
string[] values = new string[] { "home", "work" };
var orx = gg.Where(x => x.ProductAttributes.Any(pa => values.Contains(pa.AttributeId));
or even "home,work".Contains(pa.AttributeId)
should work, if your list is as reliable as your example. (I by no mean recommend this unless you can ensure that AttributeId will not be a substring of any of the list words.. such as "me")