1
I made that code
OrderItem itens = new OrderItem();
var items = _orderService.GetItemsFromOrder(orderId);
itens = items.Where(x => x.CurrencyCode == 23).Select(s => new OrderItem { ProductId = s.ProductId, CurrencyCode = s.CurrencyCode.GetValueOrDefault() }).ToList();
and you’re making that mistake:
Cannot implicitly Convert type System.Collections.Generic.List 'CSP.SubscriptionCenter.Core.domain.Orders.Orderitem' to 'CSP.SubscriptionCenter.Core.domain.Orders.Orderitem'
But the lambda I typed her as OrderItem
, then it was like this:
items >> Iqueryable
Items >> Orderitem
In the case of Currencycode in Orderitem is a nullable, so I did it in the expression
CurrencyCode = s.CurrencyCode.GetValueOrDefault()
How do I resolve this above mentioned error?
OBS: In the error message I removed the <> symbols, because it was giving problems at quotar time and I put quote(').
You are trying to assign a List to an Orderitem type variable, that is the error, what is your question? If you only want an Orderitem you can’t do Tolist at the end.
– MauroAlmeida