Как получить значение EntityKey?
Как получить значение EntityKey?
Я старался:
Строка x = Customer.EntityKey.EntityKeyValues [0].Value;
String x = Customer.EntityKey.EntityKeyValues [0].Value.ToString ();
String x = Customer.EntityKey.EntityKeyValues;
String x = Customer.EntityKey.EntityKeyValues.ToString ();
Заканчивается: Ссылка на объект не установлена на экземпляр объекта.
Пожалуйста помоги. Спасибо
1 ответ
Решение
Как вы сообщили, что вы получаете Object reference not set to an instance of an object
вы можете проверить наличие null
ссылка;
String x = (Custormer == null ? null :
Customer.EntityKey == null ? null :
Customer.EntityKey.EntityKeyValues.Length == 0 ? null :
Customer.EntityKey.EntityKeyValues[0].Value);