Git Product home page Git Product logo

Comments (20)

quan01994 avatar quan01994 commented on August 19, 2024

I can't reproduce the error. :)
i used UseRowNumberForPaging
but still translate 'offset'

from linq2db.entityframeworkcore.

quan01994 avatar quan01994 commented on August 19, 2024

If I come across this problem again,i will reopen this issue

from linq2db.entityframeworkcore.

sdanyliv avatar sdanyliv commented on August 19, 2024

Just for information, linq2db supports all T-SQL dialects starting from SQL Server 2000

from linq2db.entityframeworkcore.

quan01994 avatar quan01994 commented on August 19, 2024
     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.

quan01994 avatar quan01994 commented on August 19, 2024

The first few operations were successful。

image

image

from linq2db.entityframeworkcore.

sdanyliv avatar sdanyliv commented on August 19, 2024

Show me the EF logs.
linq2db - should log executed queries.

from linq2db.entityframeworkcore.

sdanyliv avatar sdanyliv commented on August 19, 2024

Looks like SQL Server version auto-detection fails.
Could you please send result of this query:

Select @@version

from linq2db.entityframeworkcore.

MaceWindu avatar MaceWindu commented on August 19, 2024

@sdanyliv, FIY, autodetection should use compatibility level of database, not @@Version. We had this change in linq2db for 2.2

from linq2db.entityframeworkcore.

quan01994 avatar quan01994 commented on August 19, 2024

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.

sdanyliv avatar sdanyliv commented on August 19, 2024

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.

quan01994 avatar quan01994 commented on August 19, 2024

My program is now running normally,
Sometimes this problem occurs,

from linq2db.entityframeworkcore.

sdanyliv avatar sdanyliv commented on August 19, 2024

Linq2db logs which sql dialect is used. Analyse that and please send result from compatibility level query.

from linq2db.entityframeworkcore.

quan01994 avatar quan01994 commented on August 19, 2024

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.

sdanyliv avatar sdanyliv commented on August 19, 2024

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.

quan01994 avatar quan01994 commented on August 19, 2024

Now I can't reproduce the problem.
If it happens again, I will submit the log information.

from linq2db.entityframeworkcore.

quan01994 avatar quan01994 commented on August 19, 2024

image
but i'm 2008

from linq2db.entityframeworkcore.

quan01994 avatar quan01994 commented on August 19, 2024

When I restart, it may get better
image
how about set dbconfig in startup.

from linq2db.entityframeworkcore.

sdanyliv avatar sdanyliv commented on August 19, 2024

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.

quan01994 avatar quan01994 commented on August 19, 2024

query this in dbcontext?
SELECT compatibility_level FROM sys.databases WHERE name = db_name()
in sqlserver managent
it's 100

from linq2db.entityframeworkcore.

sdanyliv avatar sdanyliv commented on August 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.