bitfoundation / bitplatform

Build all of your apps using what you already know and love ❤️
https://bitplatform.dev
MIT License
1.07k stars 222 forks source link

EF7 (RC1) - Cannot Skip() and Take() in SQL Server 2008 #116

Closed behzad888 closed 3 years ago

behzad888 commented 6 years ago

I'm getting the error Incorrect syntax near 'OFFSET'. Invalid usage of the option NEXT in the FETCH statement. because SQL Server 2008 doesn't recognize it.

So, based on aspnet/EntityFrameworkCore#4616 I think this method should be changed!?

ysmoradi commented 6 years ago

? You're mentioning some code in SqliteDbContextObjectsProvider which is related to Sqlite, not Sql server, I can't get it!

behzad888 commented 6 years ago

Whoops! my bad!

This line actually

ysmoradi commented 6 years ago

It has nothing to do with Offset/Next/Fetch etc. Could you please provide me more details? This code only provides a connection to ef core context options.

behzad888 commented 6 years ago

We implement paging option for web API on top of repositories. When we use Take and Skip methods of Dynamic.Linq dependency we got Offset/Next/Fetch etc. problem to Invoke UseSqlServer.

btw, If I use dbContextOptionsBuilder.UseSqlServer(dbConnection, c => c.UseRowNumberForPaging()) instead Invoke method it works correctly

ysmoradi commented 6 years ago

You can inherit from DbContextObjectsProvider directly and use your own logic there. Then register that class and AppStartup. Sql server version 2012 and later have support for this, and this is a recommended approach too, so I think we may not change this code. Do you agree?

behzad888 commented 6 years ago

Sure, I agree. I think we need to prepare documentation and samples for these situations. I'll create a sample and merge as soon as possible then I'll close this issue with your opinion.

ysmoradi commented 6 years ago

Thanks so much @behzad888 👍

pataoftnahiara commented 3 years ago

hello help please in error "SqlException: Sintaxis incorrecta cerca de 'OFFSET'."

ysmoradi commented 3 years ago

hello help please in error "SqlException: Sintaxis incorrecta cerca de 'OFFSET'."

https://github.com/bitfoundation/bitframework/issues/116#issuecomment-413488749

behzad888 commented 3 years ago

UseRowNumberForPaging has been removed EF Core 3.x

https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-3.x/breaking-changes#userownumberforpaging-has-been-removed