1 分页
2 // skip 3 results then take 10
3
4 var query1 = new Query {Page = Page.At(3, 10)};
5
6 // get the first 10 results
7
8 var query2 = new Query {Page = Page.Limit(10)};
9
10 // skip 20 results
11
12 var query3 = new Query {Page = Page.Offset(20)};
13
14 //Offset=startRowIndex当前页码Limit=maximumRows每页显示的条数
15 query.Page = Mindscape.LightSpeed.Querying.Page.At(startRowIndex, maximumRows);
16
17 排序
18 var query = new Query {Order = Order.By("AddedOn").AndBy("Title")};
19
20
21 视图,存储过程
22
23 context = new LightSpeedContext<LightSpeedModelUnitOfWork>();
24 context.ConnectionString = "Data Source=192.168.0.150;Initial Catalog=Northwind;User ID=sa;password=share_23448890";
25 //context.DataProvider = "sqlServer2005";
26 using (var con = context.CreateUnitOfWork())
27 {
28 //调用视图
29
30 //实例化一个Query对象
31 Query query = new Query(Entity.Attribute("CategoryName") == "123");
32 //视图的名字
33 query.ViewName = "View_Categories";
34
35 IList<Category> results = con.Find<Category>(query);
36
37 foreach (var item in results)
38 {
39 Console.WriteLine(item.CategoryName);
40 }
41
42 //直接調用存储过程
43 IList<Category> ca = con.ProcCagegories();
44
45 //要传的参数值數組
46 //ProcedureParameter[] parameter =
47 //{
48 //new ProcedureParameter("",123),
49 //new ProcedureParameter("fd",321)
50 //};
51
52 //存儲過程帶參數的 参数分别为存储过程名字,所传數組参数对象
53 //ProcedureQuery query = new ProcedureQuery("Proc_Cagegories", parameter)
54 //IList<Category> ca2 = con.Find<Category>(query);
55
56 Console.WriteLine(ca.Count());
57 foreach (var item in ca)
58 {
59 Console.WriteLine(item.Id);
60 }
61 }
62 Console.ReadLine();
63 }