通过c# Concat进行分组

本文关键字:Concat 通过 | 更新日期: 2023-09-27 18:11:17

我需要有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;
}

通过c# Concat进行分组

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

…没什么可说的了

这可能有帮助:

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