mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
- 修复 JsonMap 与导航属性的联表查询报错的 bug;#996
This commit is contained in:
parent
9fc91f1501
commit
3a453d918d
@ -14,6 +14,7 @@ public static class FreeSqlJsonMapCoreExtensions
|
|||||||
static MethodInfo MethodJsonConvertDeserializeObject = typeof(JsonConvert).GetMethod("DeserializeObject", new[] { typeof(string), typeof(Type) });
|
static MethodInfo MethodJsonConvertDeserializeObject = typeof(JsonConvert).GetMethod("DeserializeObject", new[] { typeof(string), typeof(Type) });
|
||||||
static MethodInfo MethodJsonConvertSerializeObject = typeof(JsonConvert).GetMethod("SerializeObject", new[] { typeof(object), typeof(JsonSerializerSettings) });
|
static MethodInfo MethodJsonConvertSerializeObject = typeof(JsonConvert).GetMethod("SerializeObject", new[] { typeof(object), typeof(JsonSerializerSettings) });
|
||||||
static ConcurrentDictionary<Type, ConcurrentDictionary<string, bool>> _dicJsonMapFluentApi = new ConcurrentDictionary<Type, ConcurrentDictionary<string, bool>>();
|
static ConcurrentDictionary<Type, ConcurrentDictionary<string, bool>> _dicJsonMapFluentApi = new ConcurrentDictionary<Type, ConcurrentDictionary<string, bool>>();
|
||||||
|
static object _concurrentObj = new object();
|
||||||
|
|
||||||
public static ColumnFluent JsonMap(this ColumnFluent col)
|
public static ColumnFluent JsonMap(this ColumnFluent col)
|
||||||
{
|
{
|
||||||
@ -52,13 +53,17 @@ public static class FreeSqlJsonMapCoreExtensions
|
|||||||
e.ModifyResult.StringLength = -2;
|
e.ModifyResult.StringLength = -2;
|
||||||
if (_dicTypes.TryAdd(e.Property.PropertyType, true))
|
if (_dicTypes.TryAdd(e.Property.PropertyType, true))
|
||||||
{
|
{
|
||||||
FreeSql.Internal.Utils.GetDataReaderValueBlockExpressionObjectToStringIfThenElse.Add((LabelTarget returnTarget, Expression valueExp, Expression elseExp, Type type) =>
|
lock (_concurrentObj)
|
||||||
{
|
{
|
||||||
return Expression.IfThenElse(
|
FreeSql.Internal.Utils.dicExecuteArrayRowReadClassOrTuple[e.Property.PropertyType] = true;
|
||||||
Expression.TypeIs(valueExp, e.Property.PropertyType),
|
FreeSql.Internal.Utils.GetDataReaderValueBlockExpressionObjectToStringIfThenElse.Add((LabelTarget returnTarget, Expression valueExp, Expression elseExp, Type type) =>
|
||||||
Expression.Return(returnTarget, Expression.Call(MethodJsonConvertSerializeObject, Expression.Convert(valueExp, typeof(object)), Expression.Constant(settings)), typeof(object)),
|
{
|
||||||
elseExp);
|
return Expression.IfThenElse(
|
||||||
});
|
Expression.TypeIs(valueExp, e.Property.PropertyType),
|
||||||
|
Expression.Return(returnTarget, Expression.Call(MethodJsonConvertSerializeObject, Expression.Convert(valueExp, typeof(object)), Expression.Constant(settings)), typeof(object)),
|
||||||
|
elseExp);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user