您好
我在构建一个好的LINQ查询时遇到了一些问题,它可以找到系统 - 系统“包含”一个或多个部分。这些部件有一个referencepart,搜索基于它。
数据库:
伪代码:
查找SystemPartCollection包含systemId和所有partId的系统,该系统链接到以下referenceId。
我有一些SQL代码......但我需要它在linq
-- specified ReferencePartID
DECLARE @p0 Int = 1
DECLARE @p1 Int = 3
-- number of destinct ReferencePartID
DECLARE @p2 Int = 2
SELECT *
FROM [System] AS [t0]
CROSS APPLY
(
SELECT max([t2].ReferencePartID) as maxID, [t2].ReferencePartID from [SystemPartCollection] AS [t1]
INNER JOIN [Part] AS [t2] ON [t1].[PartID] = [t2].[PartID]
WHERE
([t0].[SystemID] = [t1].[SystemID] AND ([t2].[ReferencePartID] = @p0 OR [t2].[ReferencePartID] = @p1))
GROUP BY [t2].ReferencePartID
) partSearch
WHERE maxID >= @p2
任何?