'Чтение' Вызова платформы объекта, когда datareader закрывается [закрытый]

Вы можете реорганизовать его как функцию и вернуть значение Enum, которое представляет истинный случай:

if(something != -1)
    return MyEnum.Something;
if(somethingelse != -1)
    return MyEnum.SomethingElse;
if(etc != -1)
    return MyEnum.SomethingElseEntirely;
return MyEnum.None;
11
задан Dofs 12 June 2009 в 20:04
поделиться

1 ответ

The entity framework uses lazy evaluation. This means that the query is not actually executed against the database when you create it, it is executed when you actually need the data out. Consequently, the data context must still be open when you process the query.

Converting the query to an IList will force the query to be executed. If the data context is closed at this point you will get an error like this.

I can't explain why you didn't get this before if you haven't changed any code, but this is what I would be looking at.

Perhaps post your code, this might help diagnose the problem.

26
ответ дан 3 December 2019 в 02:52
поделиться
Другие вопросы по тегам:

Похожие вопросы: