I have the below code:
public static List<ResponseSupplier> Feza_ReturnSuppliers(string country, string locale, string rtype, string scat, string sscat, string bill, int? comp, double? inc, int? loi, bool? fc, int? hf)
{
string query = string.Format(Queries[SqlQueries.returnquery], country, locale, rtype, scat, sscat, bill, comp, inc, loi, fc, hf);
IList<ExpandoObject> suppliersRaw = DatabaseHelper.MultiResponseComplex(conn, query,
new List<string>
{ "SupID",
"SupName",
"Tlabel",
"Tcode",
"dcstatic",
"dcur",
"dse",
"ltz",
"st",
"isamp",
"minf",
"sf",
"cpt",
"Scoring",
"TrustCoefficient",
"ApiIntegrated",
"fapi"
});
return suppliersRaw.Select(e => new ResponseSupplier
{
SupID = (((dynamic)e).SupID.ToString()) as string,
SupName = (((dynamic)e).SupName) as string,
Tlabel = (((dynamic)e).TierLabel) as string,
Tcode = (int?)(((dynamic)e).Tcode),
dcstatic = (double?)(((dynamic)e).dcstatic),
dcur = (((dynamic)e).dcur) as string,
dse = (((dynamic)e).dse) as string,
ltz = (((dynamic)e).ltz) as string,
st = (((dynamic)e).st) as string,
isamp = (bool?)(((dynamic)e).isamp),
minf = (double?)(((dynamic)e).minf),
sf = (double?)(((dynamic)e).sf),
cpt = (string)(((dynamic)e).cpt),
Scoring = (double?)(((dynamic)e).Scoring),
TrustCoefficient = (double?)(((dynamic)e).TrustCoefficient),
ApiIntegrated = (bool?)(((dynamic)e).ApiIntegrated),
fapi = (bool?)(((dynamic)e).fapi)
}).ToList();
I get the following error: 'Cannot convert type 'System.DBNull' to 'double?''
That is because in the db i can have Null for: 'TrustCoefficient' and 'Scoring'.
How can i get past the error, please note that i do not want to get a value like '0' when is null. That is because i need to compare the results of this list with a different one (and that one displays null for the mentioned parameters).
Is there a way to convert or parse or do something with
Scoring = (double?)(((dynamic)e).Scoring),
TrustCoefficient = (double?)(((dynamic)e).TrustCoefficient),
To allow DBNull and in the result to show Scoring = Null ?