1 回答

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊
既然您只尋找一種疾病,為什么要返回一個(gè)列表呢?下面的代碼應(yīng)該可以工作:
public Model.Disease GetDiseaseById(Guid DiseaseId)
{
? ?return (from Disease in db.Diseases
? ? ? ? ? ? ? ?where Disease.DiseaseId == DiseaseId
? ? ? ? ? ? ? ?orderby Disease.DiseaseName
? ? ? ? ? ? ? ?join d in db.Drug on Disease.DiseaseId equals d.DiseasesId
? ? ? ? ? ? ? ?select new Model.Disease
? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ?DiseaseId = Disease.DiseaseId
? ? ? ? ? ? ? ? ? ?DiseaseName = Disease.DiseaseName
? ? ? ? ? ? ? ? ? ?drug = new { DrugId = d.DrugId, DrugName = d.DrugName }
? ? ? ? ? ? ? ?}).FirstOrDefault();
}
- 1 回答
- 0 關(guān)注
- 124 瀏覽
添加回答
舉報(bào)