Fix getter creation for value type declaring types
This commit is contained in:
@@ -123,18 +123,21 @@ namespace DynamORM.Mapper
|
|||||||
|
|
||||||
private Func<object, object> CreateGetter(PropertyInfo property)
|
private Func<object, object> CreateGetter(PropertyInfo property)
|
||||||
{
|
{
|
||||||
if (property == null || !property.CanRead)
|
if (property == null || !property.CanRead)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var objParm = Expression.Parameter(typeof(object), "o");
|
var objParm = Expression.Parameter(typeof(object), "o");
|
||||||
|
var target = property.DeclaringType.IsValueType
|
||||||
return Expression.Lambda<Func<object, object>>(
|
? (Expression)Expression.Convert(objParm, property.DeclaringType)
|
||||||
Expression.Convert(
|
: Expression.TypeAs(objParm, property.DeclaringType);
|
||||||
Expression.Property(
|
|
||||||
Expression.TypeAs(objParm, property.DeclaringType),
|
return Expression.Lambda<Func<object, object>>(
|
||||||
property.Name),
|
Expression.Convert(
|
||||||
typeof(object)), objParm).Compile();
|
Expression.Property(
|
||||||
}
|
target,
|
||||||
|
property.Name),
|
||||||
|
typeof(object)), objParm).Compile();
|
||||||
|
}
|
||||||
|
|
||||||
private Action<object, object> CreateSetter(PropertyInfo property)
|
private Action<object, object> CreateSetter(PropertyInfo property)
|
||||||
{
|
{
|
||||||
@@ -276,4 +279,4 @@ namespace DynamORM.Mapper
|
|||||||
|
|
||||||
#endregion Type command cache
|
#endregion Type command cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user