This commit is contained in:
@@ -13550,7 +13550,7 @@ namespace DynamORM
|
||||
/// <summary>Sets the specified value to destination object.</summary>
|
||||
/// <param name="dest">The destination object.</param>
|
||||
/// <param name="val">The value.</param>
|
||||
public void Set(object dest, object val)
|
||||
public void Set(object dest, object val, bool byProperty = false)
|
||||
{
|
||||
object value = null;
|
||||
|
||||
@@ -13564,7 +13564,7 @@ namespace DynamORM
|
||||
{
|
||||
if (val is IEnumerable<object>)
|
||||
{
|
||||
var lst = (val as IEnumerable<object>).Select(x => GetElementVal(ArrayType, x)).ToList();
|
||||
var lst = (val as IEnumerable<object>).Select(x => GetElementVal(ArrayType, x, byProperty)).ToList();
|
||||
|
||||
value = Array.CreateInstance(ArrayType, lst.Count);
|
||||
|
||||
@@ -13575,14 +13575,14 @@ namespace DynamORM
|
||||
else
|
||||
{
|
||||
value = Array.CreateInstance(ArrayType, 1);
|
||||
((Array)value).SetValue(GetElementVal(ArrayType, val), 0);
|
||||
((Array)value).SetValue(GetElementVal(ArrayType, val, byProperty), 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
value = Array.CreateInstance(ArrayType, 0);
|
||||
}
|
||||
else
|
||||
value = GetElementVal(Type, val);
|
||||
value = GetElementVal(Type, val, byProperty);
|
||||
}
|
||||
else
|
||||
value = val;
|
||||
@@ -13598,7 +13598,7 @@ namespace DynamORM
|
||||
}
|
||||
}
|
||||
|
||||
private object GetElementVal(System.Type etype, object val)
|
||||
private object GetElementVal(System.Type etype, object val, bool byProperty)
|
||||
{
|
||||
bool nullable = etype.IsGenericType && etype.GetGenericTypeDefinition() == typeof(Nullable<>);
|
||||
Type type = Nullable.GetUnderlyingType(etype) ?? etype;
|
||||
@@ -13640,7 +13640,12 @@ namespace DynamORM
|
||||
else return (nullable) ? null : (object)Guid.Empty;
|
||||
}
|
||||
else if (!typeof(IConvertible).IsAssignableFrom(type) && (IsDataContract || (!type.IsValueType && val is IDictionary<string, object>)))
|
||||
{
|
||||
if (byProperty)
|
||||
return val.MapByProperty(type);
|
||||
|
||||
return val.Map(type);
|
||||
}
|
||||
else
|
||||
try
|
||||
{
|
||||
@@ -13800,7 +13805,7 @@ namespace DynamORM
|
||||
if (PropertyMap.TryGetValue(item.Key, out cn) && item.Value != null)
|
||||
if (ColumnsMap.TryGetValue(cn.ToLower(), out dpi) && item.Value != null)
|
||||
if (dpi.Setter != null)
|
||||
dpi.Set(destination, item.Value);
|
||||
dpi.Set(destination, item.Value, true);
|
||||
}
|
||||
|
||||
return destination;
|
||||
|
||||
Reference in New Issue
Block a user