AgileEAS 5.0新增功能展示

 此随笔主旨在已经了解EAS平台搭建项目的基础上,利用EAS 5.0的新增功能快速、专业的开发属于自己的.NET企业级项目:

具体方案建立过程见【H.I.D的博客  --http://www.cnblogs.com/HelloWang/archive/2013/03/23/2977845.html】博客

一、新增系统风格 【我的桌面】

效果如下:

双击打开对应模块,操作快捷方便,界面之爽!!

二、新增Linq写法

1.Lambda 表达式 

 1    /// <summary>
 2         /// EAS 5.0 Linq 
 3         /// </summary>
 4         public void GetCommonPre()
 5         {
 6             Query<CommonPre> query = new Query<CommonPre>();
 7             var q = from c in query
 8                     select c;
 9             //1. 求和
10             decimal totalCash = q.Sum(p => p.Cash);
11             //2. OrderBy、 Skip、Take  ....
12             var v2 = q.OrderBy(p => p.ID).Skip(20).Take(10).Select(c => new { CName = c.DrugName, Num = c.Number });
13             foreach (var item in v2)
14             {
15                 //....
16             }
17         }

 

2.连接 

 1    /// <summary>
 2         /// EAS 5.0 连接
 3         /// </summary>
 4         public void GetData()
 5         {
 6             DataEntityQuery<CommonPre> com = new DataEntityQuery<CommonPre>();
 7             DataEntityQuery<RegCode> reg = new DataEntityQuery<RegCode>();
 8             //1 .连接
 9             var v1 = from c in com
10                      from d in reg
11                      where c.ID > 100 && d.Doctor == 5
12                      select new
13                      {
14                          code = c.DrugCode,
15                          drug = c.DrugName,
16                          name = d.Name,
17                          eventt = d.EventTime
18 
19                      };
20             foreach (var item in v1)
21             {
22                 //.....
23             }
24             //2.左外连接
25             var v2 = from c in com
26                      from d in reg.Where(p => p.ISPreNum == 0).Where(p => p.Doctor == c.ID).DefaultIfEmpty()
27                      where c.ID > 10
28                      select new
29                      {
30                          drugname = c.DrugName,
31                          code = c.DrugCode,
32                          name = d.Name
33                      };
34             foreach (var item in v2)
35             {
36                 //.....
37             }
38             //3.笛卡尔积
39             var v3 = from c in com
40                      from d in reg
41                      where c.ID < 10 && d.Name.Equals("张三")
42                      select new
43                      {
44                          reg = d.Code,
45                          drugname = c.DrugName,
46                          cash = c.Cash
47                      };
48             foreach (var item in v3)
49             {
50                 //.....
51             }
52         }

 3.Select

 1   /// <summary>
 2         /// EAS 5.0 Select 
 3         /// </summary>
 4         public void SelectData()
 5         {
 6             DataEntityQuery<CommonPre> comPre = new DataEntityQuery<CommonPre>();
 7             var items = comPre.Select(p => new
 8             {
 9                 name = p.DrugName,
10                 cash = p.Cash
11             });
12             int count = items.Count();
13             foreach (var item in items)
14             {
15                 //....   
16             }
17         }

 4.Group by

 1   /// <summary>
 2         /// EAS 5.0 Groupby
 3         /// </summary>
 4         public void GroupByData()
 5         {
 6             DataEntityQuery<CommonPre> comPre = new DataEntityQuery<CommonPre>();
 7             var items = from c in comPre
 8                         group c by c.ID
 9                             into g
10                             select new
11                             {
12                                 name = DrugName,
13                                 totalcash = g.Sum(o => o.Cash),
14                                 Avg = g.Average(o => o.Cash),
15                                 Max = g.Max(o => o.Number),
16                                 Min = g.Min(o => o.Number)
17                             };
18             foreach (var item in items)
19             {
20                 System.Console.WriteLine(string.Format("Name={0},totalcash={1},Avg={2},Max={3},Min={4} ", item.name, item.totalcash, item.Avg, item.Max, item.Min));
21             }
22         }

 5.Delete、Update、Count...

 1   /// <summary>
 2         /// EAS 5.0 Delete Insert Update Count 
 3         /// </summary>
 4         public void ContextData()
 5         {
 6             DataEntityQuery<CommonPre> comPre = new DataEntityQuery<CommonPre>();
 7             //查询 
 8             IList<CommonPre> list = comPre.Skip(10).Take(20).ToList();
 9             foreach (var item in list)
10             {
11                 //.....
12             }
13             //Delete
14             int countDelete = comPre.Delete(o => o.ID > 20);
15             //Update
16             int countUpdate = comPre.Update(p => new CommonPre { DrugName = "精乌胶囊", Cash = 75.2m }, p => p.ID > 20);
17             //CommonPre insertComPre = new CommonPre();
18             //insertComPre.ID = this.GetMaxID();
19             //insertComPre.DrugName = "陈皮";
20             //insertComPre.Spec = "30g/瓶";
21             //insertComPre.Insert();
22 
23             //count
24             int count = comPre.Count();
25             Console.WriteLine("CommonPre:共{0}条记录", count);
26         }

 

 

 

posted on 2013-03-24 11:35  SplendidMe  阅读(797)  评论(2编辑  收藏  举报