I have this query:
// _db derives from DbContext var toProcess = from jobItem in _db.Jobs where jobItem.State == desiredState select jobItem.ItemId; foreach (Guid itemId in toProcess ) //exception thrown on this line { // whatever }
which in most cases works fine, but from time to time a line with foreach
will throw:
System.InvalidOperationException: Invalid read attempt when data is missing.
with the following stack trace:
System.Data.SqlClient.SqlDataReader.ReadColumnHeader(Int32 i) System.Data.SqlClient.SqlDataReader.IsDBNull(Int32 i) System.Data.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue(DbDataReader reader, Int32 ordinal) System.Data.Common.Internal.Materialization.Shaper.GetColumnValueWithErrorHandling[TColumn](Int32 ordinal) System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper) System.Data.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()
which makes no sense. How to resolve this?
source share