FreeSql icon indicating copy to clipboard operation
FreeSql copied to clipboard

自动生成 "UPDATE_TIME" = getutcdate 字段,导致列重复

Open hellokuls opened this issue 3 years ago • 5 comments

问题描述及重现步骤:

数据表某列为

  [Column(Name = "update_time", IsNullable = false, ServerTime = DateTimeKind.Utc)]
  public DateTime UpdateTime { get; set; }

当去更新该字段UpdateTime 时,会导致 列名重复。

打印sql语句发现,生成如下sql:

UPDATE "xxxxxxxx" SET "IS_ACTIVATED" = :p_1, "UPDATE_TIME" = :p_2, "UPDATE_TIME" = getutcdate
      WHERE ("xxxxxx" = :exp_0)

发现多生成了 "UPDATE_TIME" = getutcdate

数据库的具体版本

达梦数据库8

安装的包

	<PackageReference Include="FreeSql.All" Version="3.0.100" />

.net framework/. net core? 及具体版本

. net core 6

hellokuls avatar Sep 20 '22 01:09 hellokuls

因为业务需要ServerTime需要保留,请问有无其他解决方案

hellokuls avatar Sep 20 '22 01:09 hellokuls

Update 代码怎么写的

2881099 avatar Sep 20 '22 04:09 2881099

fsql.Update<T>(1)
 .Set(a => a.UpdateTime == DateTime.Now)
  .ExecuteAffrows();

这样写的吧?ServerTime 规定了不能指定更新,因为每次都会附加这个字段,是否可以判断一下手工指定过的情况?

2881099 avatar Sep 20 '22 04:09 2881099

如果不能升级 FreeSql,可以考虑建多一个实体类解决。

已发布 v3.2.670-preview22020920 解决这个问题。

2881099 avatar Sep 20 '22 04:09 2881099

freesql 2.0 以上版本没有破坏性升级,可以直接升

2881099 avatar Sep 20 '22 04:09 2881099

Freesql如果字段LAST_LOGIN_TIME用了ServerTime = DateTimeKind.Utc注解,也会自动生成LAST_LOGIN_TIME?

System.Exception: 第2 行附近出现错误: 重复的列名[LAST_LOGIN_TIME] ---> Dm.DmException (0x80004005): 第2 行附近出现错误: 重复的列名[LAST_LOGIN_TIME]

hellokuls avatar Sep 28 '22 13:09 hellokuls

已经优化了 @hellokuls 需要升级

2881099 avatar Sep 28 '22 13:09 2881099

已经优化了 @hellokuls 需要升级

好的,谢谢

hellokuls avatar Sep 29 '22 01:09 hellokuls