Comments (20)
I can't reproduce the error. :)
i used UseRowNumberForPaging
but still translate 'offset'
from linq2db.entityframeworkcore.
If I come across this problem again,i will reopen this issue
from linq2db.entityframeworkcore.
Just for information, linq2db supports all T-SQL dialects starting from SQL Server 2000
from linq2db.entityframeworkcore.
var qry = from memberApply in Db.MemberApply
from branch in Db.BranchInfo
where branch.BranchCode == memberApply.BranchCode
&& branch.BranchId == id
&& memberApply.HandleStatus == 1
from wxAttention in Db.WxAttention.LeftJoin(wx => wx.WxopenId == memberApply.WxopenId)
select new MemberApplyListOutput
{
ApplyBirthday = memberApply.ApplyBirthday,
Wxavatar = wxAttention.Wxavatar,
ApplyId = memberApply.ApplyId,
ApplyName = memberApply.ApplyName,
ApplySex = memberApply.ApplySex,
ApplyTelPhone = memberApply.ApplyTelPhone,
BranchName = memberApply.BranchName,
CreateTime = memberApply.CreateTime,
OpenCardEmpName = memberApply.OpenCardEmpName,
};
result.Count = await qry.ToLinqToDB().CountAsync();
result.Data = await qry.OrderByDescending(m => m.CreateTime).Skip((page - 1) * pageSize).Take(pageSize).ToLinqToDB().ToListAsync();
i use sqlserver 2008
mydb context
public HYWCRMContext(string connectionString) : base(new DbContextOptionsBuilder<HYWCRMContext>()
.UseSqlServer(connectionString, b => b.UseRowNumberForPaging()).Options)
{
}
throw this exception
2018-08-13 11:32:59.1905|-2146232060|Hyw.Api.Empl.Infrastructure.Filters.HttpGlobalExceptionFilter|ERROR|'OFFSET' 附近有语法错误。
在 FETCH 语句中选项 NEXT 的用法无效。 System.Data.SqlClient.SqlException (0x80131904): 'OFFSET' 附近有语法错误。
在 FETCH 语句中选项 NEXT 的用法无效。
at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__122_0(Task`1 result)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
at LinqToDB.Data.DataConnection.ExecuteReaderAsync(CommandBehavior commandBehavior, CancellationToken cancellationToken) in C:\projects\linq2db\Source\LinqToDB\Data\DataConnection.Async.cs:line 165
at LinqToDB.Data.DataConnection.QueryRunner.ExecuteReaderAsync(CancellationToken cancellationToken) in C:\projects\linq2db\Source\LinqToDB\Data\DataConnection.QueryRunner.cs:line 471
at LinqToDB.Linq.QueryRunner.AsyncEnumeratorImpl`1.MoveNext(CancellationToken cancellationToken) in C:\projects\linq2db\Source\LinqToDB\Linq\QueryRunner.cs:line 441
at System.Linq.AsyncEnumerable.Aggregate_[TSource,TAccumulate,TResult](IAsyncEnumerable`1 source, TAccumulate seed, Func`3 accumulator, Func`2 resultSelector, CancellationToken cancellationToken)
at LinqToDB.AsyncExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken token) in C:\projects\linq2db\Source\LinqToDB\AsyncExtensions.cs:line 149
at Hyw.QueryServices.EFCore.MemberApplyQuery.GetListByIdAndTypeAsync(Int32 id, Int32 type, Int32 page, Int32 pageSize) in D:\VsProjects\Hyw2\src\Hyw.QueryServices.EFCore\MemberApplyQuery.cs:line 85
at Hyw.Api.Empl.Controllers.MemberApplyController.Get(BaseModel model, PageModel page) in D:\VsProjects\Hyw2\hosts\Hyw.Api.Empl\Controllers\MemberApplyController.cs:line 47
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at System.Threading.Tasks.ValueTask`1.get_Result()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
ClientConnectionId:c929e8de-6826-4ad8-8266-caaab0e55729
Error Number:102,State:1,Class:15
but in console , it's run and No exception was thrown
It didn't happen many times
from linq2db.entityframeworkcore.
The first few operations were successful。
from linq2db.entityframeworkcore.
Show me the EF logs.
linq2db - should log executed queries.
from linq2db.entityframeworkcore.
Looks like SQL Server version auto-detection fails.
Could you please send result of this query:
Select @@version
from linq2db.entityframeworkcore.
@sdanyliv, FIY, autodetection should use compatibility level of database, not @@Version. We had this change in linq2db for 2.2
from linq2db.entityframeworkcore.
Select @@Version
Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64) Apr 2 2010 15:48:46 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) (Hypervisor)
from linq2db.entityframeworkcore.
And this query also. Run this query in your database context.
SELECT compatibility_level FROM sys.databases WHERE name = db_name()
And just for clarification. Do you cahnge compatibility level during application execution?
from linq2db.entityframeworkcore.
My program is now running normally,
Sometimes this problem occurs,
from linq2db.entityframeworkcore.
Linq2db logs which sql dialect is used. Analyse that and please send result from compatibility level query.
from linq2db.entityframeworkcore.
how to get this logger in asp.net core
i use nlog
public static void Main(string[] args)
{
NLog.LogManager.LoadConfiguration("NLog.config");
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.SetMinimumLevel(LogLevel.Trace);
})
.UseNLog()
.UseStartup<Startup>();
from linq2db.entityframeworkcore.
If you are using EF Core, it has logging. Our integration uses the same mechanism.
https://docs.microsoft.com/en-us/ef/core/miscellaneous/logging
from linq2db.entityframeworkcore.
Now I can't reproduce the problem.
If it happens again, I will submit the log information.
from linq2db.entityframeworkcore.
from linq2db.entityframeworkcore.
When I restart, it may get better
how about set dbconfig in startup.
from linq2db.entityframeworkcore.
I'm interested in this information:
SELECT compatibility_level FROM sys.databases WHERE name = db_name()
Also as workaround you can override class LinqToDBForEFToolsImplDefault
and implement method CreateSqlServerProvider
with the following code:
protected override IDataProvider CreateSqlServerProvider(SqlServerVersion version, string connectionString)
{
return new SqlServerDataProvider(ProviderName.SqlServer2008, SqlServerVersion.v2008);
}
And assign on startup this implementation:
LinqToDBForEFTools.Implementation = new MyImplementation();
from linq2db.entityframeworkcore.
query this in dbcontext?
SELECT compatibility_level FROM sys.databases WHERE name = db_name()
in sqlserver managent
it's 100
from linq2db.entityframeworkcore.
Looks like version autodetection needs to be improved,
Strange but 100
is correct value for SQL Server 2008, and we process it accordingly.
from linq2db.entityframeworkcore.
Related Issues (20)
- Log sql query strings when executing InsertWhenNotMatched, UpdateWhenMatched
- System.Diagnostics.UnreachableException: The program executed an instruction that was thought to be unreachable
- "ORA-01704 string literal too long" exception generated when trying to "upsert" BLOB type column in Oracle
- Using EF Core release version 8.0 HOT 3
- Linq2Db fails to translate recursive CTE with ef core TPH HOT 2
- Warning Message for CreateLinqToDbConnection Method HOT 2
- Using CTE with EFCore db context query?
- MissingMethodException: Method not found: SetConvertExpression HOT 1
- Mapping EF `HasConversion<string>` ignored
- BulkCopy throws an Exception with ComplexProperty (Complex Type)
- Integration with EFCore.NetTopologySuite HOT 1
- Locking PostgreSQL Advice
- Not handling JSON-conversion of IList<string>, a native feature in EFCore HOT 2
- Issue with Merge into TPH table and EF Entities HOT 1
- PK of Entity not set after bulk copy HOT 1
- Properties mapping to PostgreSQL Json/JsonB types is not working.
- BulkCopy not converting Guids to binary(16) on MariaDB HOT 3
- JSON column properties are all null when doing merge operation in MSSQL server
- Inheritance Discriminator is not defined
- NodaTime Period BulkCopy not mapping HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linq2db.entityframeworkcore.