I have tried inserting an orderby into this query in every conceivable spot, but can’t get it to work. In this linq query, I am pulling a list of unitMixes related to a single property. There is a field called createDate in the unitMixes table that I would like to order the results by, this seems simple but I just can’t quite get my mid around method syntax yet.
var viewModel = new propertyDetailData();
viewModel.properties = db.properties.Where(s => s.propertyId == id).Single();
viewModel.unitMixes = db.properties.Where(s => s.propertyId == id).Single().unitMixes;
Thanks in advance,
john
You can do the orderby on the list.
You don’t need to get the list and then do
.Single()you can search theSingle()element thatequalsyourdelegate