I've recently upgraded to devart 7.5 and a few functions are not working properly. Specifically, I've got a function that returns an IEnumerable:
protected IEnumerable<BudgetTotals> getTotals(decimal groupId, decimal budgetId)
{
using (SsinpatDataContext dc = new SsinpatDataContext())
{
object[] ids = new object[2] { groupId, budgetId };
string sqlStr = "..."
var query = dc.ExecuteQuery<BudgetTotals>(sqlStr, ids);
return query;
}
}
To this point it all works fine, and the return variable "query
" holds the correct values.
The problem is that when calling getTotals
the object is not set:
...
var query = getTotals(grpId,bdgId);
foreach(BudgetTotals bt in query)
{
...
}
Now, when control reaches "in" in the foreach instruction an exception is thrown with the message "Object not set to an instance of an object"
, which is puzzling me because
a) it was working fine and
b) the object is set within the getTotals
funcion.
I could work things around by changing the return value from IEnumerable
to BudgetTotals[]
, and returning query.ToArray
. I tried it and it works. The main issue here is all the other functions that return an IEnumerable.
Before overhauling the application, I'd like to understand why or what is causing this difference in behaviour from devart 6.3 to 7.5.
Thanks in advance