他找到了解决办法。你是最棒的@都铎·卡伦:我编辑了第二个答案来检查AllowFiltering属性,并去掉了第一个答案(这会更复杂)。哇。谢谢你是一个linq天才:))它们都能工作,并且认为第二个使用更干净的sql会更快一些。我还没有弄清楚如何测试NpPr
他找到了解决办法。你是最棒的@都铎·卡伦:我编辑了第二个答案来检查AllowFiltering属性,并去掉了第一个答案(这会更复杂)。哇。谢谢你是一个linq天才:))它们都能工作,并且认为第二个使用更干净的sql会更快一些。我还没有弄清楚如何测试NpPr,linq,linq-to-sql,linq-to-entities,linq-to-objects,Linq,Linq To Sql,Linq To Entities,Linq To Objects,他找到了解决办法。你是最棒的@都铎·卡伦:我编辑了第二个答案来检查AllowFiltering属性,并去掉了第一个答案(这会更复杂)。哇。谢谢你是一个linq天才:))它们都能工作,并且认为第二个使用更干净的sql会更快一些。我还没有弄清楚如何测试NpProductSpecificationAttribute是否将AllowFiltering属性设置为trueI。我最终设法对该属性进行了测试。比我想象的容易多了。谢谢你的解决方案。你是最棒的@Tudor Carean:我编辑了第二个答案来检查Al
他找到了解决办法。你是最棒的@都铎·卡伦:我编辑了第二个答案来检查AllowFiltering属性,并去掉了第一个答案(这会更复杂)。哇。谢谢你是一个linq天才:))它们都能工作,并且认为第二个使用更干净的sql会更快一些。我还没有弄清楚如何测试NpProductSpecificationAttribute是否将AllowFiltering属性设置为trueI。我最终设法对该属性进行了测试。比我想象的容易多了。谢谢你的解决方案。你是最棒的@Tudor Carean:我编辑了第二个答案来检查AllowFiltering属性,并去掉了第一个答案(这会更复杂)。
-- gets the SpecificationAttributeOptionIDs that are in the FilteredSpecs list, but don't match
SELECT * FROM #FilteredSpecs [fs]
WHERE [fs].SpecificationAttributeOptionID NOT IN
(
-- gets the SpecificationAttributeOptionIDs that match
SELECT psam.SpecificationAttributeOptionID
FROM dbo.Nop_Product_SpecificationAttribute_Mapping psam
WHERE psam.AllowFiltering = 1 AND psam.ProductID = 1
)
var query = from p in Products
where (p.NpProductSpecificationAttributes.Select(a => filters.Contains(a.NpSpecificationAttributeOption.SpecificationAttributeOptionId)).Count() == 0)
select p;
var query = Products.Where(
p => FilteredSpec.All(
fs => p.NpProductSpecificationAttributes.Any(
a => a.NpSpecificationAttributeOption.AllowFiltering &&
a.NpSpecificationAttributeOption.SpecificationAttributeOptionId == fs)));
var query = from p in Products
where !p.NpProductSpecificationAttributes.Except(filters).Any() &&
!filters.Except(p.NpProductSpecificationAttributes).Any()
select p;
var filterset = new HashSet<filteritemtype>(filters);
var query = from p in Products
where filterset.SetEquals(new HashSet<itemtype>(p.NpProductSpecificationAttributes))
select p;