I have two classes ShoppingCart and CartItems like this:
public class ShoppingCart
{
public Guid Id { get; set; }
public DateTime CreatedOn { get; set; }
public Guid OwnerId { get; set; }
public ICollection<CartItem> Items { get; set; }
}
public class CartItem
{
public Guid Id { get; set; }}
public int Quantity { get; set; }
public Guid ProductId { get; set; }
public Guid ShoppingCartId { get; set; }
}
I want get all CartItems by ownerId using this method:
public IEnumerable<CartItem> GetCartItems(Guid ownerId)
{
return _shoppingCarts.Where(row => row.OwnerId == ownerId)
.Select(row => row.Items)
.ToList() ;
}
but it returns an error :
Cannot implicitly convert type System.Collections.Generic.List<System.Collections.Generic.ICollection<CartItem>>'to System.Collections.Generic.IEnumerable<CartItem>