Однако я обнаружил, что это вызывает исключение SqlNullValueException при выполнении следующего кода. >
Код: Выделить всё
var customerId = 5 // a valid key
var db = GetMyDbContext() // my code to get the DbContext
var cust = db.MyExtCustomers.AsNoTracking().SingleOrDefault(x => x.CustomerID == customerId);
System.Data.SqlTypes.SqlNullValueException: 'Data is Null. Этот метод
или свойство нельзя вызвать для значений NULL.'
[img]https://i .sstatic.net/zZHfZ75n.png[/img]
Стек вызовов
Код: Выделить всё
Microsoft.Data.SqlClient.dll!Microsoft.Data.SqlClient.SqlDataReader.GetString(int i) Line 2122 C#
[Lightweight Function]
Microsoft.EntityFrameworkCore.Relational.dll!Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable.Enumerator.MoveNext() Unknown
System.Linq.dll!System.Linq.Enumerable.TryGetSingle(System.Collections.Generic.IEnumerable source, out bool found) Line 7391 C#
[Lightweight Function]
Microsoft.EntityFrameworkCore.dll!Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute(System.Linq.Expressions.Expression query) Unknown
Microsoft.EntityFrameworkCore.dll!Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute(System.Linq.Expressions.Expression expression) Unknown
dll!Helpers.DataAccessStd2.MakeReadOnlyProperties(string connectionString, int jobId) Line 439 C#
Подробнее здесь: https://stackoverflow.com/questions/790 ... eexception
Мобильная версия