我想知道有没有办法把这两者结合起来。有两个多个db集。我已经试过用同样的变量来写了。有什么想法吗?
public JsonResult GetProductByPDLN(int pdlnId, int copcCode)
{
_context.Configuration.ProxyCreationEnabled = false;
var prod = _context.ProductLines
.Where(pl => pl.Id == pdlnId)
.Select(p => p.Products)
.ToList();
var copc = _context.ProfitCenters
.Where(c => c.Id == copcCode)
.Select(p => p.ProductLines)
.ToList();
return Json(prod && copc, JsonRequestBehavior.AllowGet);
}发布于 2022-08-16 19:58:36
要么创建一个新类,要么创建匿名类。类似于这样的东西:
public JsonResult GetProductByPDLN(int pdlnId, int copcCode)
{
_context.Configuration.ProxyCreationEnabled = false;
var prod = _context.ProductLines
.Where(pl => pl.Id == pdlnId)
.Select(p => p.Products)
.ToList();
var copc = _context.ProfitCenters
.Where(c => c.Id == copcCode)
.Select(p => p.ProductLines)
.ToList();
return Json(new {ProductLines = prod, ProfitCenters = copc}, JsonRequestBehavior.AllowGet);
}https://stackoverflow.com/questions/73379543
复制相似问题