public JsonResult Statisticquery()
{
db = new NorthwindDBContext(false);
db1 = new NorthwindDBContext(false);
var model = from obj in db.Products
join obj1 in db1.Categories
on obj.CategoryID equals obj1.CategoryID
select new
{
obj.Category,
obj.CategoryID,
obj.Discontinued,
obj.ProductID,
obj.Order_Details,
obj.ProductName,
obj.QuantityPerUnit,
obj.ReorderLevel,
obj.Supplier,
obj.SupplierID,
obj.UnitPrice,
obj.UnitsInStock,
obj.UnitsOnOrder
};
return Json(model, JsonRequestBehavior.AllowGet);
}
错误:“指定的LINQ表达式包含对与不同上下文关联的查询的引用。”
我无法创建json,无法在mvc中使用linq查询