I am trying to implement paging on one of my DB tables using .Skip() and .Take().
Here's my code snippet:
public IEnumerable FetchAll(int startIndex, int pageSize)
{
return Database.OpenConnection(m_ConnectionString)["Account"].All().Skip(startIndex).Take(startIndex).Cast();
}
and am getting the following error:
{"Incorrect syntax near 'dbo'."}
The command that is generated by Simple.data is:
WITH __Data AS (SELECT [dbo].[Account].[AccountID],[dbo].[Account].[InstanceName], ROWNUMBER() OVER(ORDER BY [dbo].[Account].[AccountID], [dbo].[Account].[InstanceName]) AS [#_]
from [dbo].[Account])
SELECT [dbo].[Account].[ID],[dbo].[Account].[AccountID],[dbo].[Account].[InstanceName],[dbo].[Account].[UserGroup],[dbo].[Account].[Enable],[dbo].[Account].[ChangePassword],[dbo].[Account].[ReadOnly],[dbo].[Account].[PasswordPhone],[dbo].[Account].[Name],[dbo].[Account].[Country],[dbo].[Account].[City],[dbo].[Account].[State],[dbo].[Account].[Zip],[dbo].[Account].[Address],[dbo].[Account].[Phone],[dbo].[Account].[Email],[dbo].[Account].[Comment],[dbo].[Account].[IRD],[dbo].[Account].[Status],[dbo].[Account].[RegistrationDate],[dbo].[Account].[LastDate],[dbo].[Account].[Leverage],[dbo].[Account].[AgentAccount],[dbo].[Account].[Balance],[dbo].[Account].[PreviousMonthBalance],[dbo].[Account].[PreviousBalance],[dbo].[Account].[Credit],[dbo].[Account].[InterestRate],[dbo].[Account].[Taxes],[dbo].[Account].[PreviousMonthEquity],[dbo].[Account].[PreviousEquity],[dbo].[Account].[SendReports],[dbo].[Account].[UserColor],[dbo].[Account].[Equity],[dbo].[Account].[Margin],[dbo].[Account].[MarginLevel],[dbo].[Account].[MarginFree],[dbo].[Account].[ModifyTime] FROM Data JOIN [dbo].[Account] ON [dbo].[Account].[AccountID] = Data.[AccountID] [dbo].[Account].[InstanceName] = _Data.[InstanceName] AND [#_] BETWEEN 3 AND 4
My DB table has 2 primary keys AccountID (bigint) and InstanceName (nvarchar(64).
Works fine with DB tables with a single primary key, but errors out on multiples.
I am trying to implement paging on one of my DB tables using .Skip() and .Take().
Here's my code snippet: public IEnumerable FetchAll(int startIndex, int pageSize)
{
return Database.OpenConnection(m_ConnectionString)["Account"].All().Skip(startIndex).Take(startIndex).Cast();
}
and am getting the following error: {"Incorrect syntax near 'dbo'."}
The command that is generated by Simple.data is: WITH __Data AS (SELECT [dbo].[Account].[AccountID],[dbo].[Account].[InstanceName], ROWNUMBER() OVER(ORDER BY [dbo].[Account].[AccountID], [dbo].[Account].[InstanceName]) AS [#_] from [dbo].[Account]) SELECT [dbo].[Account].[ID],[dbo].[Account].[AccountID],[dbo].[Account].[InstanceName],[dbo].[Account].[UserGroup],[dbo].[Account].[Enable],[dbo].[Account].[ChangePassword],[dbo].[Account].[ReadOnly],[dbo].[Account].[PasswordPhone],[dbo].[Account].[Name],[dbo].[Account].[Country],[dbo].[Account].[City],[dbo].[Account].[State],[dbo].[Account].[Zip],[dbo].[Account].[Address],[dbo].[Account].[Phone],[dbo].[Account].[Email],[dbo].[Account].[Comment],[dbo].[Account].[IRD],[dbo].[Account].[Status],[dbo].[Account].[RegistrationDate],[dbo].[Account].[LastDate],[dbo].[Account].[Leverage],[dbo].[Account].[AgentAccount],[dbo].[Account].[Balance],[dbo].[Account].[PreviousMonthBalance],[dbo].[Account].[PreviousBalance],[dbo].[Account].[Credit],[dbo].[Account].[InterestRate],[dbo].[Account].[Taxes],[dbo].[Account].[PreviousMonthEquity],[dbo].[Account].[PreviousEquity],[dbo].[Account].[SendReports],[dbo].[Account].[UserColor],[dbo].[Account].[Equity],[dbo].[Account].[Margin],[dbo].[Account].[MarginLevel],[dbo].[Account].[MarginFree],[dbo].[Account].[ModifyTime] FROM Data JOIN [dbo].[Account] ON [dbo].[Account].[AccountID] = Data.[AccountID] [dbo].[Account].[InstanceName] = _Data.[InstanceName] AND [#_] BETWEEN 3 AND 4
My DB table has 2 primary keys AccountID (bigint) and InstanceName (nvarchar(64).
Works fine with DB tables with a single primary key, but errors out on multiples.