EF core GroupJoin

Scaffold-DbContext "server=192.168.0.001;database=xxx;user id=sa;password=xxx;" 
Microsoft.EntityFrameworkCore.SqlServer -Tables TabManager -OutputDir DbModels11

 


                var accounttw = await _concardContext.TabRecord
                    .GroupJoin(_concardContext.WxTemperature, t1 => t1.AccountNo, t2 => t2.Accountno,
                        (t1, t2) => new
                        {
                            t1.Name,
                            t1.Depart,
                            Temperature = t2
                        })
                   .SelectMany(a => a.Temperature.DefaultIfEmpty(), (a, b) => new
                   {
                       a.Name,
                       a.Depart,
                       Bodytemperaturet = b.Pushtime.Date == model.datetime.Date ? b.Bodytemperature : "",
                       Pushtime = b.Pushtime.Date == model.datetime.Date ? b.Pushtime.ToString("HH:mm:ss MM月dd日") : "",
                   })
                    .Where(w => w.Depart == model.DepList)
                    .ToListAsync();

 

 

你可能感兴趣的:(.net,core,EF)