标签:.sh arp orderby HERE 排序 类型 list wms 要求
WebTestDBEntities db = new WebTestDBEntities();
var userInfoList = from u in db.UserInfo where u.ID == 10 select u;
var userInfoList = from u in db.UserInfo where u.ID >= 1 select new { Name = u.UserName, Pwd = u.UserPass }; foreach (var userInfo in userInfoList) { Response.Write(userInfo.Name + ":" + userInfo.Pwd + "<br/>"); }
var userInfoList = db.UserInfo.Where<UserInfo>(u => u.ID > 0); foreach (var userInfo in userInfoList) { Response.Write(userInfo.UserName + ":" + userInfo.UserPass + "<br/>"); }
var userInfoList = db.UserInfo.Where<UserInfo>(u => u.ID > 0).Select(a => new { Name = a.UserName, Pwd = a.UserPass }); foreach (var userInfo in userInfoList) { Response.Write(userInfo.Name + ":" + userInfo.Pwd + "<br/>"); }
var userInfoList = db.UserInfo.Where<UserInfo>(c => true).OrderBy<UserInfo, int>(u => u.ID).Select(u => new { Name = u.UserName,Email=u.Email });//升序排序 var userInfoList = db.UserInfo.Where<UserInfo>(c => true).OrderByDescending<UserInfo, int>(u => u.ID).Select(u => new { Name = u.UserName, Email = u.Email });//降序排序 var userInfoList = (from u in db.UserInfo select u).OrderByDescending<UserInfo, int>(c => c.ID).Select(u => new { Name = u.UserName, Email = u.Email });
int pageIndex = 2; int pageSize = 2; var userInfoList = db.UserInfo.Where<UserInfo>(c => true).OrderBy<UserInfo, int>(u => u.ID).Skip<UserInfo>((pageIndex - 1) * pageSize).Take<UserInfo>(pageSize); foreach (var userInfo in userInfoList) { Response.Write(userInfo.UserName + "<br/>"); }
语法要求:
static
this
关键字修饰,而且类型是所扩展的类型public static string ShowMsg(this string ext, string msg) { return string.Format("<span style=‘color:red‘>{0}</span>", msg); }
string tempStr = string.Empty; string resultStr = tempStr.ShowMsg("扩展方法示例"); Response.Write(resultStr);
标签:.sh arp orderby HERE 排序 类型 list wms 要求
原文地址:https://www.cnblogs.com/ZaraNet/p/9634093.html