6 个解决方案
#1
var values = from u in users
where u.ID < 6
orderby u.Username descending,u.ID ascending
select u;
where u.ID < 6
orderby u.Username descending,u.ID ascending
select u;
#2
var q = db.Customers.OrderBy(c => c.City).ThenBy(c => c.ContactName).ToList();
#3
正解
#4
3Q 刚在网上也找到了。。
#5
其实 有多种写法:
orderby c.City,c.ContactName descending
OrderBy(c=>c.City).ThenByDescending(c=>c.ContactName).ToList();
.OrderByDescending(c=ContactName).OrderBy(c=>c.City).ToList()
所要注意的是,多个OrderBy操作时,级连方式是按逆序。对 于降序的,用相应的降序操作符替换即可。
orderby c.City,c.ContactName descending
OrderBy(c=>c.City).ThenByDescending(c=>c.ContactName).ToList();
.OrderByDescending(c=ContactName).OrderBy(c=>c.City).ToList()
所要注意的是,多个OrderBy操作时,级连方式是按逆序。对 于降序的,用相应的降序操作符替换即可。
#6
学习,哈哈哈哈哈哈
#1
var values = from u in users
where u.ID < 6
orderby u.Username descending,u.ID ascending
select u;
where u.ID < 6
orderby u.Username descending,u.ID ascending
select u;
#2
var q = db.Customers.OrderBy(c => c.City).ThenBy(c => c.ContactName).ToList();
#3
正解
#4
3Q 刚在网上也找到了。。
#5
其实 有多种写法:
orderby c.City,c.ContactName descending
OrderBy(c=>c.City).ThenByDescending(c=>c.ContactName).ToList();
.OrderByDescending(c=ContactName).OrderBy(c=>c.City).ToList()
所要注意的是,多个OrderBy操作时,级连方式是按逆序。对 于降序的,用相应的降序操作符替换即可。
orderby c.City,c.ContactName descending
OrderBy(c=>c.City).ThenByDescending(c=>c.ContactName).ToList();
.OrderByDescending(c=ContactName).OrderBy(c=>c.City).ToList()
所要注意的是,多个OrderBy操作时,级连方式是按逆序。对 于降序的,用相应的降序操作符替换即可。
#6
学习,哈哈哈哈哈哈