linq - asp.net mvc multiple table join with groupby clause returning duplicates -


i fetching data multiple tables using joins , 1 o table image attached below causing issue. table keeps track of status of tests, want tests have process id 11 tracking table multiple rows reutrning causing repeating of 1 record 3 times in view trying aplly groupby on bookingdid , max trackid unique identity of table unable linq query below. help.

dc_tstatustrack table

here linq query:

using (var db = new bc_limsentities())             {                 var result = (from d in db.dc_tpatient_bookingd                               join m in db.dc_tpatient_bookingm on d.bookingid equals m.bookingid                               m in a.defaultifempty()                               join p in db.dc_tpatient on m.prid equals p.prid b                               p in b.defaultifempty()                               join t in db.dc_tp_test on d.testid equals t.testid c                               t in c.defaultifempty()                               //join mt in db.dc_tp_tmethod on t.testid equals mt.testid j                               //from mt in j.defaultifempty()                               // join gm in db.dc_tp_groupm on t.groupid equals gm.groupid e                               //from gm in e.defaultifempty()                               join pn in db.dc_tpanel on m.panelid equals pn.panelid f                               pn in f.defaultifempty()                               join og in db.dc_tp_organization on m.clientid equals og.orgid g                               og in g.defaultifempty()                               join w in db.dc_tp_ward on m.wardid equals w.wardid h                               w in h.defaultifempty()                               join tb in db.dc_tp_branch on m.branchid equals tb.branchid                               tb in i.defaultifempty()                               join bd in db.dc_tp_refdoctors on m.doctorid equals bd.doctorid k                               bd in k.defaultifempty()                               join dt in db.dc_tstatustrack on d.bookingdid equals dt.bookingdid l                               dt in l.defaultifempty()                                      d.processid == 5                                 && t.subdepartmentid == subdepartmentid                                           && fromdate <= m.enteredon && m.enteredon <= datetime.now                                    && d.status != "h"                                    && datetime.now > d.deliverytime                                    && dt.processid == 11                                   select new { d, p, m, t, bd, pn, dt }).distinct().tolist(); 

i did not worked me:

group new { d, p, m, t, bd, pn, dt } new { dt.bookingdid } mno 

any appreciated


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -