时间:2022-11-15 09:46:46 | 栏目:.NET代码 | 点击:次
var info = from p in entity.Users where p.ID >= 10 orderby p.ID descending select p; foreach (var item in info) { Console.WriteLine("ID:" + item.ID + " " + "登录名:" + item.LoginName + " " + "密码:" + item.Password); }
var info2 = entity.Users.Where<User>(p => p.ID >= 10).OrderByDescending(p => p.ID); foreach (var item in info) { Console.WriteLine("ID:" + item.ID + " " + "登录名:" + item.LoginName + " " + "密码:" + item.Password); }
var info3 = ((IObjectContextAdapter)entity).ObjectContext.CreateQuery<User>(strSQL); foreach (var item in info) { Console.WriteLine("ID:" + item.ID + " " + "登录名:" + item.LoginName + " " + "密码:" + item.Password); }
try { string strSQL2 = "SELECT * FROM Users WHERE ID>=10 ORDER BY ID DESC"; var info4 = entity.Database.SqlQuery<User>(strSQL2); foreach (var item in info) { Console.WriteLine("ID:" + item.ID + " " + "登录名:" + item.LoginName + " " + "密码:" + item.Password); } } catch (Exception ex) { Console.WriteLine(ex.Message); }