0

我有以下想要转换为 Lambda 表达式的 SQL。

SELECT DISTINCT Make FROM
(
   SELECT DISTINCT [Option] AS Make FROM [dbo].[ItemCategoryDetailOptions]
   WHERE [IsHidden] = 0 AND [Retired] is null
   UNION
   SELECT DISTINCT [Brand] AS Make FROM [dbo].[Items] WHERE [Brand] is not null
) AS result
WHERE Make LIKE '%LG%'
4

2 回答 2

1
itemCategoryDetailOptions.Where(x => !x.IsHidden && x.Retired == null)
                         .Select(x => x.Option)
                         .Concat(items.Where(x => x.Brand != null)
                                      .Select(x => x.Brand))
                         .Distinct()
                         .Where(x => x.Contains("LG"))
于 2013-09-11T10:02:32.730 回答
0
var result = ItemCategoryDetailOptions
    .Where(i => !i.IsHidden && i.Retired != null)
    .Select(i => i.Option)
    .Distinct()
    .Union(Items
      .Where(i => i.Brand != null)
      .Select(i => i.Brand)
      .Distinct()))
    .Where(i => i.Contains("LG"));
于 2013-09-11T10:04:38.530 回答