标签:des style blog http color io os 使用 ar
原文: 我的EntityFramework(2):简单的数据查询
在上一篇博文中,已经搭建了基本的框架,接下来就进行简单的数据查询,这里主要用了Linq
var companyList = from c in dbs.Company where c.ID > 417154 orderby c.CompanyName descending select new { c.ID, c.CompanyName, c.Email, c.HtmlUrl }; gvList.DataSource = companyList.ToList();//类型转换 gvList.DataBind();
using (var dbs = new Movie_DBEntities1()) { string sql = "select [Title] from Movie"; var objList2 = dbs.Database.SqlQuery<string>(sql);//此语句,仅支持单列多行的查询 foreach (var item in objList2) { Response.Write(item + "<br>"); } }
标签:des style blog http color io os 使用 ar
原文地址:http://www.cnblogs.com/lonelyxmas/p/3965590.html