1

Attempts were as follows:

var query1 = Db.ProductView.Where(w => w.DisplayFlag == "Y");
var paging = query1.Include(i => i.ProductImages).Select(s =>

                        new Products()
                        {
                            ProductCode = s.ProductCode,
                            DesignCode = s.DesignCode,
                            Code1 = s.Code1,
                            Code2 = s.Code2,
                            ProductImages = s.ProductImages.Where(i => (i.ImageNo == 1 & i.ImageType == "LS") ).Select(i => i), 
                            ProductCoupons = Db.Database.SqlQuery<Coupon>("EXEC [USP_Front_EShop_Coupon_Select_By_ProductCode] @ProductCode", s.ProductCode)

                        }
                );

However, the following error was returned:

*LINQ to Entities does not recognize the method 'System.Collections.Generic.IEnumerable `1 [Lesmore1.Models.Coupon SqlQuery [Coupon] (System.String, System.Object [])' method, and this method cannot be translated into a store expression. Help us understand what is going wrong ..

4

1 回答 1

1

SqlQueryreturn IEnumerable<T>,这可能就是您收到该错误的原因。

尝试将.Single()or放在.First()调用 to 之后SqlQuery以获取单个对象,或.Select()获取Where()一系列对象。

于 2013-01-30T05:53:12.060 回答