ととを使用Entity Framework 4.1 code first
していASP.NET MVC 3
ます。Razor view
ValueInjecter
私のビューモデル:
public class ProductViewModel
{
public int Id { get; set; }
public string SKU { get; set; }
public string Name { get; set; }
public ICollection<Specification> Specifications { get; set; }
}
モデルクラス:
public class Product : IEntity
{
public int Id { get; set; }
public string SKU { get; set; }
public string Name { get; set; }
public virtual ICollection<Specification> Specifications { get; set; }
}
商品のリストを返し、各商品をビューモデルにマッピングする必要があるアクションメソッド。
public ActionResult JsonGetProductList()
{
IEnumerable<Product> productList = productService.GetAll();
// Mapping
IList<ProductViewModel> viewModelList = productList.Select(c => new ProductViewModel().InjectFrom(c)).Cast<ProductViewModel>().ToList();
}
次のエラーでマッピング部分にエラーが発生しています。
There is already an open DataReader associated with this Command which must be closed first.
これをどのように修正しますか?