我需要endResult以ID降序排列,我不确定c#Linq是如何工作的。任何帮助都会很棒。由C#Concat分组?
private void textBox6_Leave(object sender, EventArgs e)
{
DataClasses3DataContext db = new DataClasses3DataContext();
int matchedAdd = (from c in db.GetTable<prop>()
where c.streetNum.Contains(textBox1.Text) && c.Direction.Contains(textBox2.Text) && c.street.Contains(textBox4.Text) && c.SUFF.Contains(textBox6.Text)
select c.ID).Single();
var before = (from c in db.GetTable<prop>()
where c.ID < matchedAdd
orderby c.PARCEL descending
select c).Take(6);
var after = (from c in db.GetTable<prop>()
where c.ID > matchedAdd
orderby c.PARCEL
select c).Take(6);
var endResult = after.Concat(before);
dgvBRT.DataSource = endResult;
}
可能重复:http://stackoverflow.com/questions/298725/multiple-order-by-in-linq – 2013-04-29 17:23:39
听起来你甚至没有试图解决这个问题问题。你有没有在*全部*四处看看如何使用LINQ订购一个序列? – Servy 2013-04-29 17:25:42
@Servy yep我什么也没做。我刚来这里,并没有丝毫尝试。 –
korrowan
2013-04-29 17:46:25