Hier ist, was ich habe:Return Einheit mit Untertischkollektion
public class StudentHealthInfoType
{
public int StudentHealthInfoId { get; set; }
public bool? HasAllergies { get; set; }
public List<HealthInfoMedicationType> HealthInfoMedicationType { get; set;}
}
public class HealthInfoMedicationType
{
public int HealthInfoMedicationId { get; set; }
public string MedicationName { get; set; }
}
var result = (from u in context.StudentHealthInfos
from m in context.HealthInfoMedications
where u.RegistrationId == registrationId
&& u.StudentHealthInfoId == m.StudentHealthInfoId
select new StudentHealthInfoType
{ StudentHealthInfoId = u.StudentHealthInfoId,
HasAllergies = u.HasAllergies, HealthInfoMedicationType = new HealthInfoMedicationType
{ HealthInfoMedicationId = m.HealthInfoMedicationId,
MedicationName = m.MedicationName
}
}).FirstOrDefault();
ich diesen Fehler erhalten, die Show ist bei HealthInfoMedicationType = new HealthInfoMedicationType
kann nicht implizit Typ ‚Dis.QueryManager konvertieren. HealthFormTypes.HealthInfoMedicationType‘zu '
Hea' System.Collections.Generic.List lthInfoMedicationType muss eine Sammlung von Elementen sein, die für einen StudentHealthInfoType-Datensatz zurückgegeben wurden. Wie muss ich meine Objekte einrichten und dann so umwandeln, dass diese Abfrage funktioniert?
können Sie mir sagen, was Sie abfragen möchten? Erwartetes Ergebnis –
var result = context.StudentHealthInfos.Include (x => x.HealthInfoMedicationType). FirstOrDefault (f => f.RegistrationId == 1); –
Welcher Typ ist 'context.StudentHealthInfos'? –