Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor WebAssembly Handling a null and not null value

$
0
0

i am trying to make a service for API that can handle a null and not null value for the date. i am making a report for a corresponding date. this is what i tried but when i checked the swagger the other date will be affected as null for all even if the other date has a value already.*

 public async Task<List<DailyTimeRecord>> GetAllDailyTimeRecordsAsync(){  var timeLogs = await context.time_log  .GroupBy(g => new{  g.user_id,  Date = g.date_time.Date })  .Select(t => new DailyTimeRecord{  user_id = t.Key.user_id,  name = context.user.Where(u => u.id == t.Key.user_id).Select(u => u.name).FirstOrDefault(),  date_time = t.Max(log => log.date_time),  report = context.work_report      .Where(w => w.user_id == t.Key.user_id && w.report_date.Date == t.Key.Date)       .Select(w => w.report)      .FirstOrDefault()}) .OrderBy(r => r.name) .ThenBy(r => r.date_time) .ToListAsync();  return timeLogs;

}

*

this is my swagger value. this 06/16 should not be null*{"user_id": 1,"name": "Jhon","report": null,"date_time": "2024-06-16T12:49:00"},{"user_id": 1,"name": "Jhon","report": null,"date_time": "2024-09-02T08:05:00"}*

  • i already tried asking AI but still it does not handle a null and not null value *

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>