值对象中的属性用ColumnName另起的列名在update语句中不生效(insert和select语句中无问题) 返回
SqlSugar
处理完成
1
190
Monody 发布于1个月前
悬赏:0 飞吻
昨天大佬修复了值对象中的属性用ColumnName另起的列名在insert语句中不生效的问题。
但update语句中依然不生效。
SqlSugarCore:5.1.4.167-preview35
数据库:Oracle 11gR2
Demo:
using Microsoft.Extensions.Configuration; using SqlSugar; namespace SqlSugarDemo; public static class ValueObjectPropertyColumnNameInvalid { public static async Task Run() { ISqlSugarClient db = GetDb(); db.CodeFirst.InitTables<MyEntity3>(); MyEntity3 entity = new() { Id = Guid.NewGuid(), ValueObject = new MyValueObject3 { VOId = Guid.NewGuid(), Name = "Name" } }; await db.Insertable(entity).ExecuteCommandAsync(); // 此处问题已修复 entity.ValueObject.Name = "qwerqwerqewrasdfasdfasdf"; int a = await db.Updateable(entity).ExecuteCommandAsync(); // 生成的update语句中字段名未应用通过ColumnName另起的列名 Console.WriteLine(a); } 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 { [SugarColumn(IsPrimaryKey = true)] 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; } }
热忱回答(1)
-
fate sta VIP01个月前
SqlSugarCore 5.1.4.167-preview36
已修复
0 回复