我有一个包含地址的表,在按街道名称和街道号排序后,我需要按顺序检索其中的至少 13 个。这两个字段都存储为 nvarchar,因此 .take 将不起作用,因为据我所知,它仅适用于 int。问题是 ID 字段按所谓的 BRT 编号排序,由于重新评估,该编号仅在 80% 的情况下与街道名称/街道编号相关。
有任何想法吗?
当前代码如下所示。
private void textBox5_Leave(object sender, EventArgs e)
{
DataClasses3DataContext db = new DataClasses3DataContext();
int matchedAdd = (from c in db.GetTable<prop>()
where c.LOC.Contains(textBox1.Text) && c.Direction.Contains(textBox2.Text) && c.LOC.Contains(textBox4.Text) && c.LOC.Contains(textBox5.Text)
select c.ID).Single();
var before = (from c in db.GetTable<prop>()
where c.ID <= matchedAdd
orderby c.ID
orderby c.ID descending
select c).Take(7);
var after = (from c in db.GetTable<prop>()
where c.ID > matchedAdd
orderby c.ID
select c).Take(6);
var endResult = before.Union(after);
dgvBRT.DataSource = endResult.OrderByDescending(i => i.streetNum);
}