我首先创建了一些实体和代码。
public class Car
{
public int CarId { get; set; }
public string Title { get; set; }
public ICollection<CarDetails> CarDetails;
}
public class Detail
{
public int DetailId { get; set; }
public string Title { get; set; }
public ICollection<CarDetails> CarDetails { get; set; }
}
如何选择详情并通过Car-&gt;标题订购?这些表与CarDetail表相关,存储两者的密钥。我尝试了类似于详细信息=
的内容details.Where(x => x.DetailTypeId == id).OrderBy(x => x.DetailTypeId)
.ThenBy(x => x.CarDetails.First().Car.Title)
.ThenBy(x => x.Title)
它需要是IEnumerable才能执行,但我需要IQueryable。