下面的代碼產生錯誤:LINQ到實體無法識別自定義的方法
LINQ to Entities does not recognize the method
System.String GenerateSubscriptionButton(Int32)
method, and this method cannot be translated into a store expression.
如何創建LINQ到實體正確的自定義的方法呢?
var model = _serviceRepository.GetProducts().Select(p => new ProductModel
{
Id = p.Id,
Name = p.Name,
Credits = p.Credits,
Months = p.Months,
Price = p.Price,
PayPalButton = GenerateSubscriptionButton(p.Id)
});
private string GenerateSubscriptionButton(int id)
{
return new PaymentProcessor.PayPalProcessor().CreateSubscriptionButton(id);
}
非常感謝你..這個答案讓我的一天:) .. – NMathur