Marius Vasile

Marius Vasile

  • 594
  • 1.9k
  • 144.8k

asp.net core razor json null data trigger error

Mar 17 2021 4:34 PM
I have a json whic gets data from 4 tables. one of it has no value and because of that I have nothing in my view
  1. public async Task<JsonResult> OnGetDetailsAsync(string id1, int id2)    
  2. {    
  3.     var woplanner = await _context.WOPlanners.FirstAsync(s => s.WOMainID == id1 && s.WONumberS == id2);    
  4.     var woapprover = await _context.WOApprovers.FirstAsync(s => s.WOMainID == id1 && s.WONumberS == id2);    
  5.     var woplannerS = await _context.WOPlannerSCHs.FirstAsync(s => s.WOMainID == id1 && s.WONumberS == id2);    
  6.     var woreports = await _context.WOReports.FirstAsync(s => s.WOMainID == id1 && s.WONumberS == id2);    
  7.   
  8.     WOD obj = new WOD    
  9.     {    
  10.         WOPlanner = woplanner,    
  11.         WOApprover = woapprover,    
  12.         WOPlannerSCH = woplannerS,    
  13.         WOReport = woreports    
  14.     };    
  15.   
  16.     return new JsonResult(obj);    
  17. }
WOPlannerSCH has no data now, how do I fix this? 

Answers (2)