I alredy have this:
public static object GetDBValue(object ObjectEvaluated)
{
if (ObjectEvaluated == null)
return DBNull.Value;
else
return ObjectEvaluated;
}
used like:
List<SqlParameter> Params = new List<SqlParameter>();
Params.Add(new SqlParameter("@EntityType", GetDBValue(EntityType)));
Now i wanted to keep the same interface but extend that to use it with nullable
public static object GetDBValue(int? ObjectEvaluated)
{
if (ObjectEvaluated.HasValue)
return ObjectEvaluated.Value;
else
return DBNull.Value;
}
public static object GetDBValue(DateTime? ObjectEvaluated)
{...}
but i want only 1 function GetDBValue for nullables. How do I do that and keep the call as is is? Is that possible at all?
I can make it work like:
public static object GetDBValue<T>(Nullable<T> ObjectEvaluated) where T : struct
{
if (ObjectEvaluated.HasValue)
return ObjectEvaluated.Value;
else
return DBNull.Value;
}
But the call changes to:
Params.Add(new SqlParameter("@EntityID ", GetDBValue<int>(EntityID)));