-
Notifications
You must be signed in to change notification settings - Fork 862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InsertOrUpdate 若字段名称为Index等关键字时语句执行失败 #816
Comments
我的临时解决方案 var type = fsql.CodeFirst.GetTableByEntity(typeof(ProductionDispatchWorker));
if (type.Columns.TryGetValue(nameof(ProductionDispatchWorker.Index), out var columnInfo))
columnInfo.Attribute.Name = new FreeSql.SqlServer.SqlServerUtils(fsql).QuoteSqlName(columnInfo.Attribute.Name); |
打印一下 SQL |
var iou = fsql.InsertOrUpdate<tbiou05>().SetSource(new tbiou05 { id = 1, index = "01" });
var sql = iou.ToSql();
class tbiou05
{
public int id { get; set; }
public string index { get; set; }
} MERGE INTO [tbiou05] t1
USING (SELECT 1 as id, N'01' as index ) t2 ON (t1.[id] = t2.id)
WHEN MATCHED THEN
update set [index] = t2.index
WHEN NOT MATCHED THEN
insert ([id], [index])
values (t2.id, t2.index); t2的字段名没有括起来 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
原始错误:
尝试修复:VicBilibily@24f3e2a UnitTest:VicBilibily@e64247d 但是改动后需要改动较多的单元测试
数据库的具体版本
安装的包
.net framework/. net core? 及具体版本
The text was updated successfully, but these errors were encountered: