码迷,mamicode.com
首页 > 其他好文 > 详细

ORM操作(二)20141129

时间:2014-11-30 23:01:26      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:ar   on   2014   art   bs   text   对象   ca   br   

查询所有 var q = from p in context.Info select p; var q = context.Info; 但条件查询 var q = from p in context.Info where p.Code=="p003" select p; var q = context.Info.Where(p => p.Code=="p003"); 多条件查询 var q = from p in context.Car where p.Price > 30 && p.Brand=="b002" select p; var q = context.Car.Where(p => p.Price > 30 && p.Brand == "b002"); var q = context.Car.Where(p => p.Price > 30).Where(p => p.Brand == "b002"); var q = from p in context.Car where p.Price > 30 || p.Brand == "b002" select p; var q = context.Car.Where(p => p.Price > 30 || p.Brand == "b002"); 模糊查询: var q = from p in context.Car where p.Name.Contains("5") select p; //包含 var q = from p in context.Car where p.Name.StartsWith("奥迪") select p;//开头 var q = from p in context.Car where p.Name.EndsWith("奥迪") select p;//结尾 var q = context.Car.Where(p => p.Name.Contains("5"));//包含 var q = context.Car.Where(p => p.Name.StartsWith("奥迪"));//开头 var q = context.Car.Where(p => p.Name.EndsWith("型"));//结尾 var q = from p in context.Car where p.Name.Substring(2, 1) == "5" select p;//第三个字符 var q = context.Car.Where(p => p.Name.Substring(2,1) == "5");//第三个字符是5 Distinct查询 var q = (from p in context.Car select p.Brand).Distinct();//去重 var q = context.Car.Select(p=>p.Brand).Distinct();//去重 连接查询——对象之间的关联关系点出来的。 var q = context.Car.Where(p => p.Brand1.Productor.Prod_Name=="一汽丰田");

ORM操作(二)20141129

标签:ar   on   2014   art   bs   text   对象   ca   br   

原文地址:http://www.cnblogs.com/DORCASQING/p/4133852.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!