From afb82a7e6f2d3074f69ac30606d4b2104d0d01dd Mon Sep 17 00:00:00 2001 From: xuejiaming <326308290@qq.com> Date: Sun, 3 Jul 2022 22:27:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ValuesController.cs | 8 ++++++++ samples/Sample.SqlServer/Startup.cs | 14 +++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/samples/Sample.SqlServer/Controllers/ValuesController.cs b/samples/Sample.SqlServer/Controllers/ValuesController.cs index c04e8a2f..d3cf977b 100644 --- a/samples/Sample.SqlServer/Controllers/ValuesController.cs +++ b/samples/Sample.SqlServer/Controllers/ValuesController.cs @@ -95,7 +95,15 @@ namespace Sample.SqlServer.Controllers // }; //var listAsync = await sql.ToListAsync(); //var resultx112331tt = await _defaultTableDbContext.Set().AsNoTracking().CountAsync(); + var resultx112331tt11234 = await _defaultTableDbContext.Set().Skip(2).MaxAsync(o=>o.Id); + var resultx112331tt1123 = await _defaultTableDbContext.Set().Skip(2).Take(2).ToListAsync(); + var resultx112331tt1124 = await _defaultTableDbContext.Set().Take(2).Skip(2).ToListAsync(); var resultx112331tt112 = await _defaultTableDbContext.Set().FirstOrDefaultAsync(); + var resultx112331tt2x1 = await _defaultTableDbContext.Set().OrderBy(o => o.Id).LastOrDefaultAsync(); + var resultx112331tt2x1x = await _defaultTableDbContext.Set().OrderBy(o => o.Id).SingleOrDefaultAsync(); + var resultx112331tt2x = await _defaultTableDbContext.Set().OrderBy(o => o.Id).Skip(2).LastOrDefaultAsync(); + Console.WriteLine("--------------"); + var resultx112331tt2y = await _defaultTableDbContext.Set().OrderBy(o => o.Id).Skip(2).OrderByDescending(o => o.Id).FirstOrDefaultAsync(); var resultx112331tt2 = await _defaultTableDbContext.Set().FirstOrDefaultAsync(o => o.Id == "2"); var resultx112331ttaa2 = await _defaultTableDbContext.Set().FirstOrDefaultAsync(o => o.Id == "2"); diff --git a/samples/Sample.SqlServer/Startup.cs b/samples/Sample.SqlServer/Startup.cs index 7338b8cb..e0f644ff 100644 --- a/samples/Sample.SqlServer/Startup.cs +++ b/samples/Sample.SqlServer/Startup.cs @@ -28,13 +28,13 @@ namespace Sample.SqlServer public class Startup { - //public static readonly ILoggerFactory efLogger = LoggerFactory.Create(builder => - //{ - // builder.AddFilter((category, level) => category == DbLoggerCategory.Database.Command.Name && level == LogLevel.Information).AddConsole(); - //}); + public static readonly ILoggerFactory efLogger = LoggerFactory.Create(builder => + { + builder.AddFilter((category, level) => category == DbLoggerCategory.Database.Command.Name && level == LogLevel.Information).AddConsole(); + }); // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 - + public void ConfigureServices(IServiceCollection services) { services.AddControllers(); @@ -56,8 +56,8 @@ namespace Sample.SqlServer op.MaxQueryConnectionsLimit = 5; op.UseSqlServer(builder => { - var loggerFactory = ShardingContainer.GetService(); - builder.UseLoggerFactory(loggerFactory).UseUnionAllMerge(); + //var loggerFactory = ShardingContainer.GetService(); + builder.UseLoggerFactory(efLogger).UseUnionAllMerge(); }); op.ReplaceTableEnsureManager(sp => new SqlServerTableEnsureManager()); op.AddDefaultDataSource("A",