In my linq query I want to query the service table which has a visitId and a deviceId. I want to be able to group by the visit but have the deviceId distinct. Currently with my setup I can group by visitId but I'm having trouble showing disitnct devices in the result when the visit is the same.
from s in db.Services.Where(condition) where s.Active && (hasSupportGeneralAccess || s.Visit.Site.Branch.Users.Any(u => u.Id == userId)) && s.Device != null orderby s.Visit.Start descending group s by s.Visit into newgroup select newgroup.FirstOrDefault()
Any Help is greatly appreciated!