Exception in ShoppingCartService.cs

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 年 前
Hello.

I'm looking at the nopCommerce v1.90 source, and, in ShoppingCartService.cs, I'm getting an exception while trying to run the application in VS2010.  I simply load the solution into VS2010, click on the Log In link, enter the administrator user name and password ([email protected]/admin), and click the Log in button.  Then boom, I get the exception.

The exception is thrown in GetShoppingCartByCustomerSessionGuid method:

        public ShoppingCart GetShoppingCartByCustomerSessionGuid(ShoppingCartTypeEnum shoppingCartType, Guid customerSessionGuid)
        {
            var query = from sci in _context.ShoppingCartItems
                        orderby sci.CreatedOn
                        where sci.ShoppingCartTypeId == (int)shoppingCartType && sci.CustomerSessionGuid == customerSessionGuid
                        select sci;
            var scItems = query.ToList();  // THROWING EXCEPTION ON THIS LINE

            var shoppingCart = new ShoppingCart();
            shoppingCart.AddRange(scItems);
            return shoppingCart;
        }

and the exception is:

The specified value is not an instance of type 'Edm.Int32'
Parameter name: value

Can anyone help me identify what the error is and how to fix it?

Thanks.
13 年 前
Weird. I'm not sure whether it'll work but try the following code:


public ShoppingCart GetShoppingCartByCustomerSessionGuid(ShoppingCartTypeEnum shoppingCartType, Guid customerSessionGuid)
        {
            int shoppingCartTypeId = (int)shoppingCartType;
            var query = from sci in _context.ShoppingCartItems
                        orderby sci.CreatedOn
                        where sci.ShoppingCartTypeId == shoppingCartTypeId  && sci.CustomerSessionGuid == customerSessionGuid
                        select sci;
            var scItems = query.ToList();
            var shoppingCart = new ShoppingCart();
            shoppingCart.AddRange(scItems);
            return shoppingCart;
        }
13 年 前
Thanks Andrei!  That seems to have fixed the issue.  I'm not sure what was going on because I'm not that up-to-date on LINQ and/or EF and nopCommerce, but your fix helped.
Thanks again.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.