Cannot implicitly convert type System.Collection.Generic.IEnumberable

Posted by Cen on Stack Overflow See other posts from Stack Overflow or by Cen
Published on 2010-03-08T13:47:13Z Indexed on 2010/03/08 13:51 UTC
Read the original article Hit count: 269

Filed under:
|
|

I'm receiving this error in my Linq statement ---

Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'hcgames.ObjectClasses.ShoppingCart.ShoppingCartCartAddon'. An explicit conversion exists (are you missing a cast?)

From this query

        ShoppingCartItems items = Cart.GetAllItems();
        ShoppingCartCartAddons addons = Cart.GetAllAddons();

      var  stuff = from x in items
                    select new ShoppingCartItem()
                    {
                        ProductID = x.ProductID,
                        Quantity = x.Quantity,
                        Name = x.Name,
                        Price = x.Price,
                        Weight = x.Weight,
                        Addons =  (from y in addons
                                  where y.ShoppingCartItemID == x.ID
                                  select y)
                    };

I can not figure out how to cast this properly. Any suggestions?

Thanks for your help!

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#