FreeSql icon indicating copy to clipboard operation
FreeSql copied to clipboard

PostgresSql中,能否增加 些初始个性化处理

Open lxh023 opened this issue 2 years ago • 2 comments

Feature 特性

PostgresSql中,能否进行个性化配置(能指定默认表空间及索引空间、模式等等),在FreeSqlBuilder中指定

简要描述原因

1、 在实际开发中,出于数据安全及空间规划考虑,postgreSql不可能直接用默认的public模式,系统默认表空间,需要指定特定模式及表空间。一两张表还好,如果多张表就需要在数据库里手工更改或表迁移,就显得繁琐。如果能在FreeSqlBuilder就指定好就省却后续处理 2、插表中,对于表中,对于日期型的可空字段,freesql 会插入0001-01-01 00:00:00,而Oracle会插入null ,能否在PostgreSql也这样实现,毕竟从Oracle转到PostgreSql,对这一点还不大习惯

使用场景

面向postgresql 的codefirst开发及生产库的初始建表

lxh023 avatar Sep 18 '22 17:09 lxh023

插表中,对于表中,对于日期型的可空字段,freesql 会插入0001-01-01 00:00:00

这个搞定了,只需要在fluentApi中设定.InsertValueSql("null")就可以了,现在的需求是,能否指定默认表空间及索引空间?

lxh023 avatar Sep 19 '22 11:09 lxh023

如果 fsql.CodeFirst.GetComparisonDDLStatements<Topic>() 获取创建的 DDL string 内容,再处理 string 会不会很 low

2881099 avatar Sep 19 '22 11:09 2881099

不会,哈哈,先用。具体怎么用呢?

lxh023 avatar May 16 '23 15:05 lxh023

插表中,对于表中,对于日期型的可空字段,freesql 会插入0001-01-01 00:00:00

这个搞定了,只需要在fluentApi中设定.InsertValueSql("null")就可以了,现在的需求是,能否指定默认表空间及索引空间?

发现对于DateTime?的字段在MapType(typeof(DateTIme)下,.IsNull(true).InsertValueSql("null") 是没效果的,必须是在 DbType="timestamp(6)",在null情况下才起效果。

lxh023 avatar May 16 '23 15:05 lxh023

  1. public 模式
fsql.Aop.ConfigEntity += (_, e) => {
    e.ModifyResult.Name = $"xxx.{e.ModifyResult.Name}";
};
  1. 默认值插入问题
fsql.Aop.AuditValue += (_, e) => {
    if (e.AuditValueType == AuditValueType.Insert &&
        e.Column.CsType == typeof(DateTime) && (DateTime)e.Value < new DateTime(1970, 1, 1))
        e.Value = new DateTime(1970, 1, 1);
};

2881099 avatar May 16 '23 17:05 2881099