这是我使用的LINQ查询
var result = (from price in inventoryDb.Pricing.AsNoTracking()
where price.Quantity > 0m
select new
{
TagNo = price.TagNo,
SellingRate = price.SellingRate,
Quantity = price.Quantity
}).ToList();
根据数量
的值,我需要在列表中生成重复项。
输出:
result = [0]{TagNo="100", SellingRate=1500.00, Quantity=1}
[1]{TagNo="101", SellingRate=1600.00, Quantity=2}
期望结果:
result = [0]{TagNo="100", SellingRate=1500.00}
[1]{TagNo="101", SellingRate=1600.00}
[2]{TagNo="101", SellingRate=1600.00}
inventoryDb.Pricing.AsNoTracking()
)。我打赌会出现“NotSupportedException” :) - Ivan StoevEnumerable.Repeat
之前,只需添加.AsEnumerable()
即可。 - kiziu