(from p in this.m_dbContext.Patient
join b in (from a in this.m_dbContext.Appointments
join p in this.m_dbContext.Patient on a.Patientid equals
p.Patientid
where a.Doctorid == doctorid && a.Clinicid == clinicid
group a by a.Patientid)
on p.Patientid equals b.FirstOrDefault().Patientid
orderby p.Name
select new
{
p.Patientid,
p.Clinicid,
p.Name,
p.Mobilenumber,
p.Gender,
p.Dob,
p.Age,
p.Address,
p.City,
p.State,
p.Pincode
}).ToList().Count();
I get the below exception when i run, i use group by in order to remove the duplicates in the result set
Exception:
The LINQ expression 'FirstOrDefault(GroupByShaperExpression: KeySelector: a.patientid, ElementSelector:EntityShaperExpression: EntityType: Appointments ValueBufferExpression: ProjectionBindingExpression: EmptyProjectionMember IsNullable: False )' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.