From 73008f2ac8cc74e947483308eb06902ac8ccaf94 Mon Sep 17 00:00:00 2001 From: xuejiaming <326308290@qq.com> Date: Sat, 21 Aug 2021 09:10:52 +0800 Subject: [PATCH] 1 --- README.md | 16 ++++++++++++++++ .../Controllers/ValuesController.cs | 1 + 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index c4249929..835d0175 100644 --- a/README.md +++ b/README.md @@ -356,6 +356,22 @@ AbstractSimpleShardingYearKeyLongVirtualTableRoute |按时间戳 |yyyy | `>,>=,< // op.AddShardingTableRoute(); // }); ``` +如果数据库不支持mars但是我又要支持追踪该怎么办 +```c# + + var sresult = _defaultTableDbContext.Set().ToList(); + + var sysUserMod98 = result.FirstOrDefault(o => o.Id == "98"); + _defaultTableDbContext.Attach(sysUserMod98); + sysUserMod98.Name = "name_update"+new Random().Next(1,99)+"_98"; + await _defaultTableDbContext.SaveChangesAsync(); +--log info + info: Microsoft.EntityFrameworkCore.Database.Command[20101] + Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] + SELECT COUNT(*) + FROM [SysUserMod_01] AS [s] + WHERE [s].[Age] <= 10 +``` # 计划 diff --git a/samples/Sample.SqlServer/Controllers/ValuesController.cs b/samples/Sample.SqlServer/Controllers/ValuesController.cs index 1f9b240a..d77c412f 100644 --- a/samples/Sample.SqlServer/Controllers/ValuesController.cs +++ b/samples/Sample.SqlServer/Controllers/ValuesController.cs @@ -49,6 +49,7 @@ namespace Sample.SqlServer.Controllers var sresult = _defaultTableDbContext.Set().ToList(); var sysUserMod98 = result.FirstOrDefault(o => o.Id == "98"); + _defaultTableDbContext.Attach(sysUserMod98); sysUserMod98.Name = "name_update"+new Random().Next(1,99)+"_98"; await _defaultTableDbContext.SaveChangesAsync(); return Ok(result);