Skip to content

Commit

Permalink
- 增加 TypeHandler override FluentApi 设置;
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Aug 19, 2024
1 parent 3335a84 commit 402ff40
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions FreeSql/FreeSqlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ public IFreeSql<TMark> Build<TMark>()
{
if (e.Property.PropertyType == typeHandler.Type)
{
typeHandler.FluentApi(new ColumnFluent(e.ModifyResult, e.Property, e.EntityType));
if (_dicTypeHandlerTypes.ContainsKey(e.Property.PropertyType)) return;
if (e.Property.PropertyType.NullableTypeOrThis() != typeof(DateTime) &&
FreeSql.Internal.Utils.dicExecuteArrayRowReadClassOrTuple.ContainsKey(e.Property.PropertyType))
Expand Down
5 changes: 4 additions & 1 deletion FreeSql/Internal/Model/TypeHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FreeSql.Internal.Model.Interface;
using FreeSql.DataAnnotations;
using FreeSql.Internal.Model.Interface;
using System;
using System.Collections.Generic;
using System.Text;
Expand All @@ -12,12 +13,14 @@ public interface ITypeHandler
Type Type { get; }
object Deserialize(object value);
object Serialize(object value);
void FluentApi(ColumnFluent col);
}
}
public abstract class TypeHandler<T> : ITypeHandler
{
public abstract T Deserialize(object value);
public abstract object Serialize(T value);
public virtual void FluentApi(ColumnFluent col) { }

public Type Type => typeof(T);
object ITypeHandler.Deserialize(object value) => this.Deserialize(value);
Expand Down

0 comments on commit 402ff40

Please sign in to comment.