- 优化 TypeHandlers 支持 DateTime 映射规则;#1634

This commit is contained in:
2881099
2023-10-10 02:07:29 +08:00
parent 1f3f60f6fa
commit 58f261b5e5
30 changed files with 288 additions and 28 deletions

View File

@ -612,9 +612,10 @@ namespace FreeSql
{
if (e.Property.PropertyType == typeHandler.Type)
{
if (_dicTypeHandlerTypes.ContainsKey(e.Property.PropertyType) == false &&
if (_dicTypeHandlerTypes.ContainsKey(e.Property.PropertyType)) return;
if (e.Property.PropertyType.NullableTypeOrThis() != typeof(DateTime) &&
FreeSql.Internal.Utils.dicExecuteArrayRowReadClassOrTuple.ContainsKey(e.Property.PropertyType))
return; //基础类型无效
return; //基础类型无效DateTime 除外
if (_dicTypeHandlerTypes.TryAdd(e.Property.PropertyType, true))
{

View File

@ -2447,6 +2447,14 @@ namespace FreeSql.Internal
);
break;
case "System.DateTime":
if (TypeHandlers.ContainsKey(type))
{
foreach (var switchFunc in GetDataReaderValueBlockExpressionSwitchTypeFullName)
{
var switchFuncRet = switchFunc(returnTarget, valueExp, type);
if (switchFuncRet != null) return switchFuncRet;
}
}
tryparseExp = Expression.Block(
new[] { tryparseVarExp = Expression.Variable(typeof(DateTime)) },
new Expression[] {