2010-06-22 96 views

回答

1

不在L2S,但你可以用ExecuteStoreQuery做到這一點:

你想SQL這樣的:

SELECT 
[Project1].[C1] AS [C1], 
[Project1].[DepartmentId] AS [DepartmentId], 
[Project1].[Code] AS [Code], 
[Project1].[DepartmentName] AS [DepartmentName] 
FROM (SELECT [Project1].[DepartmentId] AS [DepartmentId], [Project1].[Code] AS [Code], [Project1].[DepartmentName] AS [DepartmentName], [Project1].[C1] AS [C1], row_number() OVER (ORDER BY [Project1].[DepartmentName] ASC) AS [row_number] 
    FROM (SELECT 
     [Extent1].[DepartmentId] AS [DepartmentId], 
     [Extent1].[Code] AS [Code], 
     [Extent1].[DepartmentName] AS [DepartmentName] 
     1 AS [C1] 
     FROM [dbo].[Department] AS [Extent1] 
    ) AS [Project1] 
) AS [Project1] 
WHERE [Project1].[row_number] % 4 = 0   
ORDER BY [Project1].[DepartmentName] ASC 

(或替代一個參數有關我的硬編碼4)

而且然後代碼如下:

var q = Context.ExecuteStoreQuery<Foo>(
    sql, params); 
相關問題