-1

次のwhere句をLinqクエリに追加したいと思います。linqを使用した以下のようなサブクエリ

WHERE (Restaurants.[IsActive] = 1) 
AND exists 
(
   select 1 from APIKeys 
   where ApiKey = 'on35e5xbt3m4cbcef4e4448t6wssg11o'
       and (KeyType = 1
       and  fk_RestaurantsID = [t2].[RestaurantsID]
       or KeyType = 2 
       and fk_RestaurantGroupID = RG.RestaurantGroupsID 
       and [t1].[fk_RestaurantsID] in 
           (SELECT RestaurantsID 
            FROM Restaurants 
            WHERE RestaurantGroupsID = RG.RestaurantGroupsID))
)
AND (0 = (COALESCE([t0].[fk_MembersID],0))) 
AND (1 = [t0].[fk_BookingStatusID]) 
AND ([t0].[Email] = 'nike.s@gmail.com') 
AND (([t0].[Phone] = '9999999990') OR ([t0].[MobilePhone] = '9999999990'))
4

1 に答える 1

0

Any()EXISTS に変換されるサブクエリを生成するために使用します。たとえば、AdventureWorks データベース サンプルの場合:

from p in Products
where p.FinishedGoodsFlag &&
      SalesOrderDetails.Any(od => od.ProductID == p.ProductID)
select new { p.ProductID, p.Name }

データベースへの次のクエリを生成します。

SELECT [t0].[ProductID], [t0].[Name]
FROM [Production].[Product] AS [t0]
WHERE ([t0].[FinishedGoodsFlag] = 1) AND (EXISTS(
    SELECT NULL AS [EMPTY]
    FROM [Sales].[SalesOrderDetail] AS [t1]
    WHERE [t1].[ProductID] = [t0].[ProductID]
    ))
于 2013-09-25T10:37:08.570 に答える