Hi All,
How can I get a GetScalar result typed in the cleanest way?
I now use:
DateTime? toReturn = null;
object result = terminals.GetScalar(TerminalFieldIndex.LastRequest, null, AggregateFunction.Max, filter);
if(result != DBNull.Value)
toReturn = (DateTime)result;
The above seems like a lot of code to get the value typed.
You could think of something like a TryGetScalar generic that has a 'out' parameter by which you define the type. Is there something like that already, or am I just being stupid by using the code I am using now and is there a better way?
Thanks.