1

試行は次のとおりです。

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)

                        }
                );

ただし、次のエラーが返されました。

*LINQ to Entities はメソッド 'System.Collections.Generic.IEnumerable `1 [Lesmore1.Models.Coupon SqlQuery [Coupon] (System.String, System.Object [])' メソッドを認識せず、このメソッドを店舗表現。何が問題なのかを理解するのを手伝ってください..

4

1 に答える 1

1

SqlQueryを返しますIEnumerable<T>。これが、そのエラーが発生する理由である可能性があります。

orの呼び出しの後に.Single()orを置いて、単一のオブジェクトを取得するか、オブジェクトのシーケンスを取得してみてください。.First()SqlQuery.Select()Where()

于 2013-01-30T05:53:12.060 に答える