Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Getting "Incorrect syntax near 'dbo'" error trying to use .skip and .take with multiple primary keys #264

Closed
thumbs90 opened this Issue Mar 14, 2013 · 0 comments

Comments

Projects
None yet
1 participant

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], ROW_NUMBER() 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment