var constructorOfferGetter =…
- User
var constructorOfferGetter = ServiceProvider.GetRequiredService(); var mediator = ServiceProvider.GetRequiredService(); var queryOffer = mediator.ResolveQuery(); var offers = queryOffer.GetOffers(new int?[] { constructorOfferGetter.GetConstructorOfferId(basket) }, DT.Now, null);
var productConfigurations = mediator.ResolveQuery<IQueryProductConfiguration>().GetProductConfigurationForOffers(offers, DT.Now, null); var newRiskProductConfig = productConfigurations.SingleOrDefault(p => p.StructId == risk.StructId);Как исправить ошибку Severity Code Description Project File Line Suppression State Error CS1061 'KeyValuePair<int, ProductConfiguration>' does not contain a definition for 'StructId' and no accessible extension method 'StructId' accepting a first argument of type 'KeyValuePair<int, ProductConfiguration>' could be found (are you missing a using directive or an assembly reference?) iRIS.KaskoLink2.Modification C:\Code\b-app-kasko\sources\App\src\Modules\iRIS.KaskoLink2.Modification\Code\Procedures\KaskoModificationProcedures.cs 160 Active
- Assistant
Ошибка, которую вы видите, сообщает, что тип
KeyValuePair<int, ProductConfiguration>не содержит определения для свойстваStructId. Из текста ошибки понятно, что вы пытаетесь получить доступ к свойствуStructIdу объектаKeyValuePair<int, ProductConfiguration>, а не у самого объектаProductConfiguration.Чтобы исправить эту ошибку, нужно скорректировать способ доступа к свойству
StructIdуProductConfiguration. Вот несколько способов, как это можно сделать:-
Использование деконструкции
var newRiskProductConfig = productConfigurations .Select(kv => kv.Value) .SingleOrDefault(p => p.StructId == risk.StructId);
-