2
我这样分配:如何使用IEnumerable分配的地方?
IEnumerable<ProductUser> products = myP2Locator.GetMasterDBC().ProductUsers;
不过,我需要其中userid =用户id
userID是我的函数参数...
有人可以告诉我怎么过滤呢?
感谢
我这样分配:如何使用IEnumerable分配的地方?
IEnumerable<ProductUser> products = myP2Locator.GetMasterDBC().ProductUsers;
不过,我需要其中userid =用户id
userID是我的函数参数...
有人可以告诉我怎么过滤呢?
感谢
你的意思是:
IEnumerable<ProductUser> products = myP2Locator
.GetMasterDBC()
.ProductUsers
.Where(pu => pu.UserId == userId);
贾斯汀的回答是完全正确的。值得注意的是:
IEnumerable<ProductUser> products = from pu in myP2Locator.GetMasterDBC().ProductUsers
where pu.UserId == userId
select pu;
将会变成与他的答案几乎相同的东西。你会看到两种语法都被使用,所以熟悉这两种语法是很好的。
谢谢我需要这个版本。 – Darren 2011-12-15 02:55:50