Код: Выделить всё
// Main model
public class MainDetails
{
[Key]
public int MainDetailId { get; set; }
public string Name { get; set; }
public ICollection SubDetails { get; set; }
}
// Sub model
public class SubDetails
{
[Key]
public int SubDetailId{ get; set; }
public string School { get; set; }
public MainDetails MainDetails { get; set; }
public int MainDetailId { get; set; }
}
Код: Выделить всё
public IQueryable SearchDetails(string school)
{
return context.MainDetails.Where(details=>details.SubDetails.School == school)
// details.SubDetails.School is an ICollection so this not working.
}
public IQueryable SearchDetails(string school)
{
return context.MainDetails.Inclue(x=>x.SubDetails).Where(details=>details.SubDetails.School == school)
// This doesn't work too
}
Извините, я новичок в вопросах отношений. Надеюсь, вы поделитесь со мной чем-нибудь. Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/486 ... s-with-ico
Мобильная версия