From e7e169ae237bec91db955e24791af9c71b710ea6 Mon Sep 17 00:00:00 2001
From: 2881099 <2881099@qq.com>
Date: Tue, 24 Dec 2024 22:17:55 +0800
Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E5=A4=8D=20GBase=20IsNull=20?=
=?UTF-8?q?=E6=97=A5=E6=9C=9F=E8=A7=A3=E6=9E=90=E9=97=AE=E9=A2=98=EF=BC=9B?=
=?UTF-8?q?#1953?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FreeSql/FreeSql.xml | 109 ++++++++++++++++++
.../FreeSql.Provider.GBase/GBaseUtils.cs | 17 ++-
2 files changed, 125 insertions(+), 1 deletion(-)
diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml
index 25f23c323..4ccbbef74 100644
--- a/FreeSql/FreeSql.xml
+++ b/FreeSql/FreeSql.xml
@@ -1087,6 +1087,93 @@
+
+
+ 动态创建实体类型
+
+
+
+
+ 配置Class
+
+ 类名
+ 类标记的特性[Table(Name = "xxx")] [Index(xxxx)]
+
+
+
+
+ 获取类型构建器,可作为要构建的Type来引用
+
+
+
+
+ 配置属性
+
+ 属性名称
+ 属性类型
+ 属性标记的特性-支持多个
+
+
+
+
+ 配置属性
+
+ 属性名称
+ 属性类型
+ 该属性是否重写父类属性
+ 属性标记的特性-支持多个
+
+
+
+
+ 配置属性
+
+ 属性名称
+ 属性类型
+ 该属性是否重写父类属性
+ 属性默认值
+ 属性标记的特性-支持多个
+
+
+
+
+ 配置父类
+
+ 父类类型
+
+
+
+
+ Override属性
+
+
+
+
+
+ Emit动态创建出Class - Type
+
+
+
+
+
+ Emit动态创建出Class - Type,不附带获取TableInfo
+
+
+
+
+
+ 首字母小写
+
+
+
+
+
+
+ 首字母大写
+
+
+
+
获取实体的主键值,以 "*|_,[,_|*" 分割,当任意一个主键属性无值时,返回 ""
@@ -5810,6 +5897,28 @@
对象池
+
+
+ 动态构建Class Type
+
+
+
+
+
+ 根据字典,创建 table 对应的实体对象
+
+
+
+
+
+
+
+ 根据实体对象,创建 table 对应的字典
+
+
+
+
+
C#: that >= between && that <= and
diff --git a/Providers/FreeSql.Provider.GBase/GBaseUtils.cs b/Providers/FreeSql.Provider.GBase/GBaseUtils.cs
index a92c0abac..d54213260 100644
--- a/Providers/FreeSql.Provider.GBase/GBaseUtils.cs
+++ b/Providers/FreeSql.Provider.GBase/GBaseUtils.cs
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Data.Common;
using System.Data.Odbc;
using System.Globalization;
+using System.Text.RegularExpressions;
namespace FreeSql.GBase
{
@@ -76,7 +77,21 @@ namespace FreeSql.GBase
}
public override string[] SplitTableName(string name) => name?.Split(new char[] { ':' }, 1);
public override string QuoteParamterName(string name) => $"?{(_orm.CodeFirst.IsSyncStructureToLower ? name.ToLower() : name)}";
- public override string IsNull(string sql, object value) => $"nvl({sql}, {value})";
+
+ readonly static Regex _regDateTime = new Regex(@"^'(\d{4,4}\-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2})(\.\d+)?'$", RegexOptions.Compiled);
+ public override string IsNull(string sql, object value)
+ {
+ if (value is string valueStr)
+ {
+ var match = _regDateTime.Match(valueStr);
+ if (match.Success)
+ {
+ if (string.IsNullOrEmpty(match.Groups[2].Value)) value = $"DATETIME({match.Groups[1].Value}) YEAR TO SECOND";
+ else value = $"DATETIME({match.Groups[1].Value}{match.Groups[2].Value}) YEAR TO FRACTION({(match.Groups[2].Value.Length - 1)})";
+ }
+ }
+ return $"nvl({sql}, {value})";
+ }
public override string StringConcat(string[] objs, Type[] types) => $"{string.Join(" || ", objs)}";
public override string Mod(string left, string right, Type leftType, Type rightType) => $"mod({left},{right})";
public override string Div(string left, string right, Type leftType, Type rightType) => $"trunc({left}/{right})";