mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
- 增加 Aop.AuditDataReader 参数属性 PropertyInfo,实现自定义拦截;
This commit is contained in:
parent
a3cb3d37df
commit
5782d6e517
@ -1084,6 +1084,82 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:FreeSql.Extensions.DynamicEntity.DynamicCompileBuilder">
|
||||||
|
<summary>
|
||||||
|
动态创建实体类型
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSql.Extensions.DynamicEntity.DynamicCompileBuilder.#ctor(IFreeSql,System.String,System.Attribute[])">
|
||||||
|
<summary>
|
||||||
|
配置Class
|
||||||
|
</summary>
|
||||||
|
<param name="className">类名</param>
|
||||||
|
<param name="attributes">类标记的特性[Table(Name = "xxx")] [Index(xxxx)]</param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSql.Extensions.DynamicEntity.DynamicCompileBuilder.Property(System.String,System.Type,System.Attribute[])">
|
||||||
|
<summary>
|
||||||
|
配置属性
|
||||||
|
</summary>
|
||||||
|
<param name="propertyName">属性名称</param>
|
||||||
|
<param name="propertyType">属性类型</param>
|
||||||
|
<param name="attributes">属性标记的特性-支持多个</param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSql.Extensions.DynamicEntity.DynamicCompileBuilder.Property(System.String,System.Type,System.Boolean,System.Attribute[])">
|
||||||
|
<summary>
|
||||||
|
配置属性
|
||||||
|
</summary>
|
||||||
|
<param name="propertyName">属性名称</param>
|
||||||
|
<param name="propertyType">属性类型</param>
|
||||||
|
<param name="isOverride">该属性是否重写父类属性</param>
|
||||||
|
<param name="attributes">属性标记的特性-支持多个</param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSql.Extensions.DynamicEntity.DynamicCompileBuilder.Property(System.String,System.Type,System.Boolean,System.Object,System.Attribute[])">
|
||||||
|
<summary>
|
||||||
|
配置属性
|
||||||
|
</summary>
|
||||||
|
<param name="propertyName">属性名称</param>
|
||||||
|
<param name="propertyType">属性类型</param>
|
||||||
|
<param name="isOverride">该属性是否重写父类属性</param>
|
||||||
|
<param name="defaultValue">属性默认值</param>
|
||||||
|
<param name="attributes">属性标记的特性-支持多个</param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSql.Extensions.DynamicEntity.DynamicCompileBuilder.Extend(System.Type)">
|
||||||
|
<summary>
|
||||||
|
配置父类
|
||||||
|
</summary>
|
||||||
|
<param name="superClass">父类类型</param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSql.Extensions.DynamicEntity.DynamicCompileBuilder.OverrideProperty(System.Reflection.Emit.TypeBuilder@,System.Reflection.Emit.MethodBuilder,FreeSql.Extensions.DynamicEntity.DynamicCompileBuilder.PropertyMethodEnum,System.String)">
|
||||||
|
<summary>
|
||||||
|
Override属性
|
||||||
|
</summary>
|
||||||
|
<param name="typeBuilder"></param>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSql.Extensions.DynamicEntity.DynamicCompileBuilder.Build">
|
||||||
|
<summary>
|
||||||
|
Emit动态创建出Class - Type
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSql.Extensions.DynamicEntity.DynamicCompileBuilder.FirstCharToLower(System.String)">
|
||||||
|
<summary>
|
||||||
|
首字母小写
|
||||||
|
</summary>
|
||||||
|
<param name="input"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSql.Extensions.DynamicEntity.DynamicCompileBuilder.FirstCharToUpper(System.String)">
|
||||||
|
<summary>
|
||||||
|
首字母大写
|
||||||
|
</summary>
|
||||||
|
<param name="input"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:FreeSql.Extensions.EntityUtil.EntityUtilExtensions.GetEntityKeyString(IFreeSql,System.Type,System.Object,System.Boolean,System.String)">
|
<member name="M:FreeSql.Extensions.EntityUtil.EntityUtilExtensions.GetEntityKeyString(IFreeSql,System.Type,System.Object,System.Boolean,System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
获取实体的主键值,以 "*|_,[,_|*" 分割,当任意一个主键属性无值时,返回 null
|
获取实体的主键值,以 "*|_,[,_|*" 分割,当任意一个主键属性无值时,返回 null
|
||||||
@ -3992,6 +4068,11 @@
|
|||||||
DataReader 对应的 Index 位置
|
DataReader 对应的 Index 位置
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:FreeSql.Aop.AuditDataReaderEventArgs.Property">
|
||||||
|
<summary>
|
||||||
|
DataReader 对应的 PropertyInfo
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="P:FreeSql.Aop.AuditDataReaderEventArgs.Value">
|
<member name="P:FreeSql.Aop.AuditDataReaderEventArgs.Value">
|
||||||
<summary>
|
<summary>
|
||||||
获取 Index 对应的值,也可以设置拦截的新值
|
获取 Index 对应的值,也可以设置拦截的新值
|
||||||
@ -5761,6 +5842,28 @@
|
|||||||
请使用 fsql.InsertDict(dict) 方法插入字典数据
|
请使用 fsql.InsertDict(dict) 方法插入字典数据
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:FreeSqlGlobalDynamicEntityExtensions.DynamicEntity(FreeSql.ICodeFirst,System.String,System.Attribute[])">
|
||||||
|
<summary>
|
||||||
|
动态构建Class Type
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSqlGlobalDynamicEntityExtensions.CreateInstance(FreeSql.Internal.Model.TableInfo,System.Collections.Generic.Dictionary{System.String,System.Object})">
|
||||||
|
<summary>
|
||||||
|
根据字典,创建 table 对应的实体对象
|
||||||
|
</summary>
|
||||||
|
<param name="table"></param>
|
||||||
|
<param name="dict"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSqlGlobalDynamicEntityExtensions.CreateDictionary(FreeSql.Internal.Model.TableInfo,System.Object)">
|
||||||
|
<summary>
|
||||||
|
根据实体对象,创建 table 对应的字典
|
||||||
|
</summary>
|
||||||
|
<param name="table"></param>
|
||||||
|
<param name="instance"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:FreeSqlGlobalExpressionCallExtensions.Between(System.DateTime,System.DateTime,System.DateTime)">
|
<member name="M:FreeSqlGlobalExpressionCallExtensions.Between(System.DateTime,System.DateTime,System.DateTime)">
|
||||||
<summary>
|
<summary>
|
||||||
C#: that >= between && that <= and<para></para>
|
C#: that >= between && that <= and<para></para>
|
||||||
|
@ -360,10 +360,11 @@ namespace FreeSql.Aop
|
|||||||
#region AuditDataReader
|
#region AuditDataReader
|
||||||
public class AuditDataReaderEventArgs : EventArgs
|
public class AuditDataReaderEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
public AuditDataReaderEventArgs(DbDataReader dataReader, int index)
|
public AuditDataReaderEventArgs(DbDataReader dataReader, int index, PropertyInfo property)
|
||||||
{
|
{
|
||||||
this.DataReader = dataReader;
|
this.DataReader = dataReader;
|
||||||
this.Index = index;
|
this.Index = index;
|
||||||
|
this.Property = property;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -375,6 +376,10 @@ namespace FreeSql.Aop
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int Index { get; }
|
public int Index { get; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// DataReader 对应的 PropertyInfo
|
||||||
|
/// </summary>
|
||||||
|
public PropertyInfo Property { get; }
|
||||||
|
/// <summary>
|
||||||
/// 获取 Index 对应的值,也可以设置拦截的新值
|
/// 获取 Index 对应的值,也可以设置拦截的新值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public object Value
|
public object Value
|
||||||
|
@ -570,7 +570,7 @@ namespace FreeSql.Internal
|
|||||||
return Utils.GetDataReaderValue(parent.Property.PropertyType, null);
|
return Utils.GetDataReaderValue(parent.Property.PropertyType, null);
|
||||||
return Utils.GetDataReaderValue(parent.CsType, null);
|
return Utils.GetDataReaderValue(parent.CsType, null);
|
||||||
}
|
}
|
||||||
object objval = Utils.InternalDataReaderGetValue(_common, dr, ++index); // dr.GetValue(++index);
|
object objval = Utils.InternalDataReaderGetValue(_common, dr, ++index, parent.Property); // dr.GetValue(++index);
|
||||||
if (dbValue != null) dbValue.DbValue = objval == DBNull.Value ? null : objval;
|
if (dbValue != null) dbValue.DbValue = objval == DBNull.Value ? null : objval;
|
||||||
if (parent.CsType != parent.MapType)
|
if (parent.CsType != parent.MapType)
|
||||||
objval = Utils.GetDataReaderValue(parent.MapType, objval);
|
objval = Utils.GetDataReaderValue(parent.MapType, objval);
|
||||||
|
@ -600,7 +600,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
var name = dr.GetName(a);
|
var name = dr.GetName(a);
|
||||||
//expando[name] = row2.GetValue(a);
|
//expando[name] = row2.GetValue(a);
|
||||||
if (expandodic.ContainsKey(name)) continue;
|
if (expandodic.ContainsKey(name)) continue;
|
||||||
expandodic.Add(name, Utils.InternalDataReaderGetValue(_commonUtils, dr, a));
|
expandodic.Add(name, Utils.InternalDataReaderGetValue(_commonUtils, dr, a, null));
|
||||||
}
|
}
|
||||||
//expando = expandodic;
|
//expando = expandodic;
|
||||||
return (T1)((object)expandodic);
|
return (T1)((object)expandodic);
|
||||||
@ -682,8 +682,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
var propGetSetMethod = prop.GetSetMethod(true);
|
var propGetSetMethod = prop.GetSetMethod(true);
|
||||||
Expression readExpAssign = null; //加速缓存
|
Expression readExpAssign = null; //加速缓存
|
||||||
if (prop.PropertyType.IsArray) readExpAssign = Expression.New(Utils.RowInfo.Constructor,
|
if (prop.PropertyType.IsArray) readExpAssign = Expression.New(Utils.RowInfo.Constructor,
|
||||||
Utils.GetDataReaderValueBlockExpression(prop.PropertyType, Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, dataIndexExp })),
|
Utils.GetDataReaderValueBlockExpression(prop.PropertyType, Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, dataIndexExp, Expression.Constant(prop) })),
|
||||||
//Expression.Call(Utils.MethodGetDataReaderValue, new Expression[] { Expression.Constant(prop.PropertyType), Expression.Call(rowExp, Utils.MethodDataReaderGetValue, dataIndexExp) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))
|
Expression.Add(dataIndexExp, Expression.Constant(1))
|
||||||
);
|
);
|
||||||
else
|
else
|
||||||
@ -692,8 +691,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
if (proptypeGeneric.IsNullableType()) proptypeGeneric = proptypeGeneric.GetGenericArguments().First();
|
if (proptypeGeneric.IsNullableType()) proptypeGeneric = proptypeGeneric.GetGenericArguments().First();
|
||||||
if (proptypeGeneric.IsEnum ||
|
if (proptypeGeneric.IsEnum ||
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple.ContainsKey(proptypeGeneric)) readExpAssign = Expression.New(Utils.RowInfo.Constructor,
|
Utils.dicExecuteArrayRowReadClassOrTuple.ContainsKey(proptypeGeneric)) readExpAssign = Expression.New(Utils.RowInfo.Constructor,
|
||||||
Utils.GetDataReaderValueBlockExpression(prop.PropertyType, Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, dataIndexExp })),
|
Utils.GetDataReaderValueBlockExpression(prop.PropertyType, Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, dataIndexExp, Expression.Constant(prop) })),
|
||||||
//Expression.Call(Utils.MethodGetDataReaderValue, new Expression[] { Expression.Constant(prop.PropertyType), Expression.Call(rowExp, Utils.MethodDataReaderGetValue, dataIndexExp) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))
|
Expression.Add(dataIndexExp, Expression.Constant(1))
|
||||||
);
|
);
|
||||||
else
|
else
|
||||||
@ -739,7 +737,8 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
foreach (var col in tb.Table.Columns.Values)
|
foreach (var col in tb.Table.Columns.Values)
|
||||||
{
|
{
|
||||||
var drvalType = col.Attribute.MapType.NullableTypeOrThis();
|
var drvalType = col.Attribute.MapType.NullableTypeOrThis();
|
||||||
var propGetSetMethod = tb.Table.Properties[col.CsName].GetSetMethod(true);
|
var colprop = tb.Table.Properties[col.CsName];
|
||||||
|
var propGetSetMethod = colprop.GetSetMethod(true);
|
||||||
if (col.CsType == col.Attribute.MapType &&
|
if (col.CsType == col.Attribute.MapType &&
|
||||||
_orm.Aop.AuditDataReaderHandler == null &&
|
_orm.Aop.AuditDataReaderHandler == null &&
|
||||||
_dicMethodDataReaderGetValue.TryGetValue(col.Attribute.MapType.NullableTypeOrThis(), out var drGetValueMethod))
|
_dicMethodDataReaderGetValue.TryGetValue(col.Attribute.MapType.NullableTypeOrThis(), out var drGetValueMethod))
|
||||||
@ -755,7 +754,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
{
|
{
|
||||||
var drvalExpCatch = Utils.GetDataReaderValueBlockExpression(
|
var drvalExpCatch = Utils.GetDataReaderValueBlockExpression(
|
||||||
col.CsType,
|
col.CsType,
|
||||||
Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, Expression.Constant(colidx) })
|
Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, Expression.Constant(colidx), Expression.Constant(colprop) })
|
||||||
);
|
);
|
||||||
blockExp.Add(Expression.TryCatch(
|
blockExp.Add(Expression.TryCatch(
|
||||||
Expression.Call(retExp, propGetSetMethod, drvalExp),
|
Expression.Call(retExp, propGetSetMethod, drvalExp),
|
||||||
@ -780,7 +779,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
{
|
{
|
||||||
var drvalExp = Utils.GetDataReaderValueBlockExpression(
|
var drvalExp = Utils.GetDataReaderValueBlockExpression(
|
||||||
col.CsType,
|
col.CsType,
|
||||||
Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, Expression.Constant(colidx) })
|
Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, Expression.Constant(colidx), Expression.Constant(colprop) })
|
||||||
);
|
);
|
||||||
blockExp.Add(Expression.Call(retExp, propGetSetMethod, Expression.Convert(drvalExp, col.CsType)));
|
blockExp.Add(Expression.Call(retExp, propGetSetMethod, Expression.Convert(drvalExp, col.CsType)));
|
||||||
}
|
}
|
||||||
|
@ -1683,12 +1683,12 @@ namespace FreeSql.Internal
|
|||||||
}
|
}
|
||||||
internal static MethodInfo MethodDataReaderGetValue = typeof(Utils).GetMethod("InternalDataReaderGetValue", BindingFlags.Static | BindingFlags.NonPublic);
|
internal static MethodInfo MethodDataReaderGetValue = typeof(Utils).GetMethod("InternalDataReaderGetValue", BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
internal static PropertyInfo PropertyDataReaderFieldCount = typeof(DbDataReader).GetProperty("FieldCount");
|
internal static PropertyInfo PropertyDataReaderFieldCount = typeof(DbDataReader).GetProperty("FieldCount");
|
||||||
internal static object InternalDataReaderGetValue(CommonUtils commonUtil, DbDataReader dr, int index)
|
internal static object InternalDataReaderGetValue(CommonUtils commonUtil, DbDataReader dr, int index, PropertyInfo property)
|
||||||
{
|
{
|
||||||
var orm = commonUtil._orm;
|
var orm = commonUtil._orm;
|
||||||
if (orm.Aop.AuditDataReaderHandler != null)
|
if (orm.Aop.AuditDataReaderHandler != null)
|
||||||
{
|
{
|
||||||
var args = new Aop.AuditDataReaderEventArgs(dr, index);
|
var args = new Aop.AuditDataReaderEventArgs(dr, index, property);
|
||||||
orm.Aop.AuditDataReaderHandler(orm, args);
|
orm.Aop.AuditDataReaderHandler(orm, args);
|
||||||
return args.Value;
|
return args.Value;
|
||||||
}
|
}
|
||||||
@ -1725,8 +1725,7 @@ namespace FreeSql.Internal
|
|||||||
|
|
||||||
if (type.IsArray) return Expression.Lambda<Func<Type, int[], DbDataReader, int, CommonUtils, RowInfo>>(
|
if (type.IsArray) return Expression.Lambda<Func<Type, int[], DbDataReader, int, CommonUtils, RowInfo>>(
|
||||||
Expression.New(RowInfo.Constructor,
|
Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })),
|
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Default(typeof(PropertyInfo)) })),
|
||||||
//Expression.Call(MethodGetDataReaderValue, new Expression[] { typeExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))
|
Expression.Add(dataIndexExp, Expression.Constant(1))
|
||||||
), new[] { typeExp, indexesExp, rowExp, dataIndexExp, commonUtilExp }).Compile();
|
), new[] { typeExp, indexesExp, rowExp, dataIndexExp, commonUtilExp }).Compile();
|
||||||
|
|
||||||
@ -1736,8 +1735,7 @@ namespace FreeSql.Internal
|
|||||||
dicExecuteArrayRowReadClassOrTuple.ContainsKey(typeGeneric))
|
dicExecuteArrayRowReadClassOrTuple.ContainsKey(typeGeneric))
|
||||||
return Expression.Lambda<Func<Type, int[], DbDataReader, int, CommonUtils, RowInfo>>(
|
return Expression.Lambda<Func<Type, int[], DbDataReader, int, CommonUtils, RowInfo>>(
|
||||||
Expression.New(RowInfo.Constructor,
|
Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })),
|
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Default(typeof(PropertyInfo)) })),
|
||||||
//Expression.Call(MethodGetDataReaderValue, new Expression[] { typeExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))
|
Expression.Add(dataIndexExp, Expression.Constant(1))
|
||||||
), new[] { typeExp, indexesExp, rowExp, dataIndexExp, commonUtilExp }).Compile();
|
), new[] { typeExp, indexesExp, rowExp, dataIndexExp, commonUtilExp }).Compile();
|
||||||
|
|
||||||
@ -1757,8 +1755,7 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
Expression read2ExpAssign = null; //加速缓存
|
Expression read2ExpAssign = null; //加速缓存
|
||||||
if (field.FieldType.IsArray) read2ExpAssign = Expression.New(RowInfo.Constructor,
|
if (field.FieldType.IsArray) read2ExpAssign = Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(field.FieldType, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })),
|
GetDataReaderValueBlockExpression(field.FieldType, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Default(typeof(PropertyInfo)) })),
|
||||||
//Expression.Call(MethodGetDataReaderValue, new Expression[] { Expression.Constant(field.FieldType), Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))
|
Expression.Add(dataIndexExp, Expression.Constant(1))
|
||||||
);
|
);
|
||||||
else
|
else
|
||||||
@ -1767,8 +1764,7 @@ namespace FreeSql.Internal
|
|||||||
if (fieldtypeGeneric.IsNullableType()) fieldtypeGeneric = fieldtypeGeneric.GetGenericArguments().First();
|
if (fieldtypeGeneric.IsNullableType()) fieldtypeGeneric = fieldtypeGeneric.GetGenericArguments().First();
|
||||||
if (fieldtypeGeneric.IsEnum ||
|
if (fieldtypeGeneric.IsEnum ||
|
||||||
dicExecuteArrayRowReadClassOrTuple.ContainsKey(fieldtypeGeneric)) read2ExpAssign = Expression.New(RowInfo.Constructor,
|
dicExecuteArrayRowReadClassOrTuple.ContainsKey(fieldtypeGeneric)) read2ExpAssign = Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(field.FieldType, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })),
|
GetDataReaderValueBlockExpression(field.FieldType, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Default(typeof(PropertyInfo)) })),
|
||||||
//Expression.Call(MethodGetDataReaderValue, new Expression[] { Expression.Constant(field.FieldType), Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))
|
Expression.Add(dataIndexExp, Expression.Constant(1))
|
||||||
);
|
);
|
||||||
else
|
else
|
||||||
@ -1809,8 +1805,7 @@ namespace FreeSql.Internal
|
|||||||
Expression.IfThen(
|
Expression.IfThen(
|
||||||
Expression.LessThan(dataIndexExp, rowLenExp),
|
Expression.LessThan(dataIndexExp, rowLenExp),
|
||||||
Expression.Return(returnTarget, Expression.New(RowInfo.Constructor,
|
Expression.Return(returnTarget, Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })),
|
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Default(typeof(PropertyInfo)) })),
|
||||||
//Expression.Call(MethodGetDataReaderValue, new Expression[] { typeExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))))
|
Expression.Add(dataIndexExp, Expression.Constant(1))))
|
||||||
),
|
),
|
||||||
Expression.Label(returnTarget, Expression.Default(typeof(RowInfo)))
|
Expression.Label(returnTarget, Expression.Default(typeof(RowInfo)))
|
||||||
@ -1829,7 +1824,7 @@ namespace FreeSql.Internal
|
|||||||
var name = row2.GetName(a);
|
var name = row2.GetName(a);
|
||||||
//expando[name] = row2.GetValue(a);
|
//expando[name] = row2.GetValue(a);
|
||||||
if (expandodic.ContainsKey(name)) continue;
|
if (expandodic.ContainsKey(name)) continue;
|
||||||
expandodic.Add(name, Utils.InternalDataReaderGetValue(commonUtils2, row2, a));
|
expandodic.Add(name, Utils.InternalDataReaderGetValue(commonUtils2, row2, a, null));
|
||||||
}
|
}
|
||||||
//expando = expandodic;
|
//expando = expandodic;
|
||||||
return new RowInfo(expandodic, fc);
|
return new RowInfo(expandodic, fc);
|
||||||
@ -1864,9 +1859,10 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
if (typetb.ColumnsByCsIgnore.ContainsKey(ctorParm.Name)) continue;
|
if (typetb.ColumnsByCsIgnore.ContainsKey(ctorParm.Name)) continue;
|
||||||
var readType = typetb.ColumnsByCs.TryGetValue(ctorParm.Name, out var trycol) ? trycol.Attribute.MapType : ctorParm.ParameterType;
|
var readType = typetb.ColumnsByCs.TryGetValue(ctorParm.Name, out var trycol) ? trycol.Attribute.MapType : ctorParm.ParameterType;
|
||||||
|
var colprop = trycol != null ? typetb.Table.Properties[trycol.CsName] : null;
|
||||||
|
|
||||||
var ispkExp = new List<Expression>();
|
var ispkExp = new List<Expression>();
|
||||||
Expression readVal = Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }));
|
Expression readVal = Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Constant(colprop) }));
|
||||||
Expression readExpAssign = null; //加速缓存
|
Expression readExpAssign = null; //加速缓存
|
||||||
if (readType.IsArray) readExpAssign = Expression.New(RowInfo.Constructor,
|
if (readType.IsArray) readExpAssign = Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(readType, readpkvalExp),
|
GetDataReaderValueBlockExpression(readType, readpkvalExp),
|
||||||
@ -1882,7 +1878,7 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
|
|
||||||
//判断主键为空,则整个对象不读取
|
//判断主键为空,则整个对象不读取
|
||||||
//blockExp.Add(Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })));
|
//blockExp.Add(Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Constant(colprop) })));
|
||||||
if (trycol?.Attribute.IsPrimary == true)
|
if (trycol?.Attribute.IsPrimary == true)
|
||||||
{
|
{
|
||||||
ispkExp.Add(
|
ispkExp.Add(
|
||||||
@ -1985,7 +1981,7 @@ namespace FreeSql.Internal
|
|||||||
}
|
}
|
||||||
var ispkExp = new List<Expression>();
|
var ispkExp = new List<Expression>();
|
||||||
var propGetSetMethod = prop.GetSetMethod(true);
|
var propGetSetMethod = prop.GetSetMethod(true);
|
||||||
Expression readVal = Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, tryidxExp }));
|
Expression readVal = Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, tryidxExp, Expression.Constant(prop) }));
|
||||||
Expression readExpAssign = null; //加速缓存
|
Expression readExpAssign = null; //加速缓存
|
||||||
if (readType.IsArray) readExpAssign = Expression.New(RowInfo.Constructor,
|
if (readType.IsArray) readExpAssign = Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(readType, readpkvalExp),
|
GetDataReaderValueBlockExpression(readType, readpkvalExp),
|
||||||
@ -2001,7 +1997,7 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
|
|
||||||
//判断主键为空,则整个对象不读取
|
//判断主键为空,则整个对象不读取
|
||||||
//blockExp.Add(Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })));
|
//blockExp.Add(Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Constant(prop) })));
|
||||||
if (flagStr.StartsWith("adoQuery") == false && //Ado.Query 的时候不作此判断
|
if (flagStr.StartsWith("adoQuery") == false && //Ado.Query 的时候不作此判断
|
||||||
trycol?.Attribute.IsPrimary == true) //若主键值为 null,则整行读取出来的对象为 null
|
trycol?.Attribute.IsPrimary == true) //若主键值为 null,则整行读取出来的对象为 null
|
||||||
{
|
{
|
||||||
@ -2088,7 +2084,7 @@ namespace FreeSql.Internal
|
|||||||
indexes2 = ctor.GetParameters().Select(c => row2.GetOrdinal(c.Name)).ToArray();
|
indexes2 = ctor.GetParameters().Select(c => row2.GetOrdinal(c.Name)).ToArray();
|
||||||
|
|
||||||
for (var c = 0; c < ctorParms.Length; c++)
|
for (var c = 0; c < ctorParms.Length; c++)
|
||||||
ctorParms[c] = Utils.InternalDataReaderGetValue(commonUtils2, row2, indexes2[c]);
|
ctorParms[c] = Utils.InternalDataReaderGetValue(commonUtils2, row2, indexes2[c], null);
|
||||||
return new RowInfo(ctor.Invoke(ctorParms), ctorParms.Length);
|
return new RowInfo(ctor.Invoke(ctorParms), ctorParms.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user