|
|
@ -5,10 +5,10 @@ namespace NzbDrone.Core.Datastore
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class CustomeMapper : DefaultMapper
|
|
|
|
public class CustomeMapper : DefaultMapper
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public override Func<object, object> GetFromDbConverter(DestinationInfo destinationInfo, Type SourceType)
|
|
|
|
public override Func<object, object> GetFromDbConverter(DestinationInfo destinationInfo, Type sourceType)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if ((SourceType == typeof(Int32) || SourceType == typeof(Int64)) && destinationInfo.Type.IsGenericType && destinationInfo.Type.GetGenericTypeDefinition() == typeof(Nullable<>))
|
|
|
|
if ((sourceType == typeof(Int32) || sourceType == typeof(Int64)) && destinationInfo.Type.IsGenericType && destinationInfo.Type.GetGenericTypeDefinition() == typeof(Nullable<>))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If it is NULLABLE, then get the underlying type. eg if "Nullable<int>" then this will return just "int"
|
|
|
|
// If it is NULLABLE, then get the underlying type. eg if "Nullable<int>" then this will return just "int"
|
|
|
|
Type genericArgument = destinationInfo.Type.GetGenericArguments()[0];
|
|
|
|
Type genericArgument = destinationInfo.Type.GetGenericArguments()[0];
|
|
|
@ -18,31 +18,19 @@ namespace NzbDrone.Core.Datastore
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int value;
|
|
|
|
int value;
|
|
|
|
Int32.TryParse(s.ToString(), out value);
|
|
|
|
Int32.TryParse(s.ToString(), out value);
|
|
|
|
if (value == 0)
|
|
|
|
return (DayOfWeek?)value;
|
|
|
|
{
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (Nullable<DayOfWeek>)value;
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return delegate(object s)
|
|
|
|
return delegate(object s)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int value;
|
|
|
|
int value;
|
|
|
|
Int32.TryParse(s.ToString(), out value);
|
|
|
|
Int32.TryParse(s.ToString(), out value);
|
|
|
|
if (value == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
return value;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return base.GetFromDbConverter(destinationInfo, SourceType);
|
|
|
|
return base.GetFromDbConverter(destinationInfo, sourceType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|