如何将与聚合函数Linq关联的多个联接转换为sql C#?
我想使用LINQtoSQL编写以下查询? 我试过这么做,但我是Linq的初学者,我在其中迷失了方向,请提供任何帮助或文章的任何提示来帮助我解决这个问题如何将与聚合函数Linq关联的多个联接转换为sql C#?,c#,sql-server,linq,linq-to-sql,linq-to-objects,C#,Sql Server,Linq,Linq To Sql,Linq To Objects,我想使用LINQtoSQL编写以下查询? 我试过这么做,但我是Linq的初学者,我在其中迷失了方向,请提供任何帮助或文章的任何提示来帮助我解决这个问题 select (s.fname + '' + s.lname ) as doctor_name , appointment_id , [date/time] , price , type ,
select (s.fname + '' + s.lname ) as doctor_name , appointment_id , [date/time] , price , type ,
patient_id
from staff s
,
(select appointment_id,[date/time] , price , apptype.type , patient_id , [doctor-id] from
AppointmentType apptype ,
( select *
from Appointments app
where app.appointment_id =
(
select Max(appointment_id) as lastApp
from Appointments app1
where app1.patient_id = app.patient_id and app.patient_id=10
)
) as rr
where apptype.id = rr.type
) as dd
where dd.[doctor-id] = s.id
任何提示,请,无论如何谢谢:)您能给我们看一下您目前编写的代码吗?至少我们知道你们实体的名称和属性。。
using (DataClasses1DataContext db = new DataClasses1DataContext())
{
var x = from apptype in db.AppointmentTypes
from rr in (
(from app in db.Appointments
where
app.appointment_id ==
(from app1 in db.Appointments
where
app1.patient_id == app.patient_id &&
app.patient_id == patient.Patient_id
select new {
app1.appointment_id
}).Max(p => p.appointment_id)
select new {
app
}))
where
apptype.id == rr.app.type
select new {
apptype.id,
// apptype.appointment_id,
///// take *** Column1 = rr.app.date_time ,
apptype.price,
apptype.type,
rr.app.patient_id // apptype.patient_id,
// Column2 = (apptype.doctor - apptype.id)
};