1

我希望能够查询一个包含正确记录的子集,然后查询前后 6 个,总共 13 行,并将它们显示在 DGV 中。拉取正确行的查询如下:

private void textBox6_Leave(object sender, EventArgs e)
    {
        DataClasses3DataContext db = new DataClasses3DataContext();

        var matchedAdd = (from c in db.GetTable<prop>()
                          where c.HOUSE_NO.Contains(textBox1.Text) && c.Direction.Contains(textBox2.Text) && c.street.Contains(textBox3.Text) && c.SUFF.Contains(textBox4.Text)
                          select c).SingleOrDefault();
    }
4

1 回答 1

0

如果 PARCEL 号码在增加,则使用您的查询来检索包裹号码。

然后:

var before = (from c in db.GetTable<prop>()
                      where c.PARCEL < retrievedParcelNumber orderby c.PARCEL descending 
                      select c).Take(6);

var after = (from c in db.GetTable<prop>()
                      where c.PARCEL > retrievedParcelNumber orderby c.PARCEL
                      select c).Take(6);
于 2013-03-05T20:45:56.207 回答