I was wondering if there was a way to combine these two. There are two multiple db sets. I've already tried putting with the same variable. Any ideas?
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);
}
Either create a new class or an anonymous. Something along these lines:
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);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.