C#Concat集团?

时间:2013-04-29 17:21:20

标签: c# winforms linq

我需要让endResult按ID降序排列,并且不确定它如何与c#Linq一起使用。任何帮助都会很棒。

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;

}

2 个答案:

答案 0 :(得分:2)

dgvBRT.DataSource = endResult.OrderByDescending(x => x.ID);

......没有什么可说的。

答案 1 :(得分:1)

这可能会有所帮助:

after.Concat(befor).OrderByDescending(i => i.ID);