주소가있는 테이블이 있는데 거리 이름과 거리 번호로 정렬 한 후 순서대로 적어도 13 개를 검색해야합니다. 두 필드 모두 nvarchar로 저장되므로 .take는 int로만 작동한다는 것을 이해할 수 있으므로 작동하지 않습니다. 문제는 ID 필드가 재평가로 인해 거리 이름/거리 번호 80 %와 만 상관되는 BRT 번호로 정렬되는 것입니다.varchar에는 .take와 같은 것이 있습니까?
아이디어가 있으십니까?
현재 코드는 다음과 같습니다. .take는 INT와 함께 작동에 대한 이해에서 작동하지 않도록
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);
}
참고 : 두 개의'orderby' 절을 사용하면 거의 좋은 아이디어가 아닙니다. 동일한 속성에 대해 두 개를 사용하는 것은 실제로는 좋지 않습니다. –
죄송합니다. 나는 다른 것을 시도하고 그것을 언급하는 것을 잊어 버렸다. – korrowan