I get the following:
Cannot implicitly convert type System.Collections.Generic.Dictionary<System.DateTime?,double?> to System.Collections.Generic.Dictionary<System.DateTime,double>
When I try to use a stored procedure within Entity Framework
Here is the code that I have:
private Dictionary<DateTime, double> GetData(string columnName)
{
return db.SysReading(columnName, Convert.ToString(LocId)).
ToDictionary( a => a.DateCollected, a => a.ElementReading);
}
I am using a call to a Stored Procedure called SysReading. When I convert it to a dictionary, the return type is nullable which I do not want.
Well it sounds like
a.DateCollectedis aDateTime?property instead ofDateTime. If you believe all keys will have values, you can just use:Or you could filter and then convert:
Alternatively, change your method to return a
Dictionary<DateTime?, double>.