在 FETCH 语句中选项 NEXT 的用法无效。

原因是sqlserver2008不支持此语法

 

一般修改方法:修改“StartUp.cs”文件

        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();

            var connection = @"Data Source=.;
Initial Catalog=xxx;Persist Security Info=True;User ID=xxxx;Password=xxxxx";
            services.AddDbContext<NoteContext>(options => options.UseSqlServer(connection, b => b.UseRowNumberForPaging()));

            services.AddScoped<Repository.INoteRepository, Repository.NoteRepository>();
            services.AddScoped<Repository.INoteTypeRepository, Repository.NoteTypeRepository>();
        }

abp修改方法:修改DbContextConfigurer

    public static class PhoneBookDbContextConfigurer
    {
        public static void Configure(DbContextOptionsBuilder<PhoneBookDbContext> builder, string connectionString)
        {
            builder.UseSqlServer(connectionString, b => b.UseRowNumberForPaging());//解决sqlserver2008不支持FETCH、NEXT
        }

        public static void Configure(DbContextOptionsBuilder<PhoneBookDbContext> builder, DbConnection connection)
        {
            builder.UseSqlServer(connection, b => b.UseRowNumberForPaging());//解决sqlserver2008不支持FETCH、NEXT
        }
    }

 

posted @ 2018-07-24 23:48  开拓丿飞  阅读(5455)  评论(1)    收藏  举报