值对象中的属性用ColumnName另起的列名在增删改查中不生效 返回
SqlSugar
处理完成
5
183
Monody 发布于1个月前
悬赏:0 飞吻
上图所示的功能异常。
如下方Demo,CodeFirst生成的列名为ColumnName设置的列名,但insert等语句中却为属性名本身
using Microsoft.Extensions.Configuration; using SqlSugar; namespace SqlSugarDemo; public static class ValueObjectPropertyColumnNameInvalid { public static Task Run() { ISqlSugarClient db = GetDb(); db.CodeFirst.InitTables<MyEntity3>(); MyEntity3 entity = new() { Id = Guid.NewGuid(), ValueObject = new MyValueObject3 { VOId = Guid.NewGuid(), Name = "Name" } }; return db.Insertable(entity).ExecuteCommandAsync(); } private static ISqlSugarClient GetDb() { ConfigurationBuilder configBuilder = new(); configBuilder.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); IConfigurationRoot configRoot = configBuilder.Build(); SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = configRoot["connStr"], DbType = DbType.Oracle, IsAutoCloseConnection = true }, db => { db.Aop.OnLogExecuting = (sql, pars) => { //获取原生SQL推荐 5.1.4.63 性能OK Console.WriteLine(UtilMethods.GetNativeSql(sql, pars)); //获取无参数化SQL 对性能有影响,特别大的SQL参数多的,调试使用 //Console.WriteLine(UtilMethods.GetSqlString(DbType.SqlServer,sql,pars)) }; //注意多租户 有几个设置几个 //db.GetConnection(i).Aop }); return Db; } } public class MyEntity3 { public Guid Id { get; init; } [SugarColumn(IsOwnsOne = true)] public MyValueObject3 ValueObject { get; set; } } public class MyValueObject3 { [SugarColumn(ColumnName = "VALUEOBJECTID")] public Guid VOId { get; set; } [SugarColumn(ColumnName = "VALUEOBJECTNAME")] public string Name { get; set; } }
生成的Insert语句:
INSERT INTO "MYENTITY3" ("ID","VOID","NAME") VALUES (:Id,:VOId,:Name)
SqlSugar: 5.1.4.167-preview34
数据库:Oracle 11gR2
热忱回答(5)
-
fate sta VIP01个月前
可以重现 ,处理中
0 回复 -
Monody VIP01个月前
@fate sta:大佬辛苦。
0 回复 -
Monody VIP01个月前
虽然最近我给值对象提了好几个bug,但我一点也不想用它了(捂脸)。用的时候要考虑的东西有点多、限制有点多。感觉这点不如EFCore
0 回复 -
fate sta VIP01个月前
SqlSugarCore 5.1.4.167-preview35
已修复
0 回复 -
fate sta VIP01个月前
过五分钟后安装
0 回复