一,向中间代码添加业务逻辑

   在RIA service中通常会涉及到一些业务逻辑不需要客户端调用,但中间层又不可或缺,也就是只在中间层中访问,客户端不需要访问,不需要将该方法公开为服务,使用 IgnoreAttribute 特性来标记该方法,这个在客户端不可见,下面的演示将添加一个新的应用,(如果应用名称不重复)该方法使用 IgnoreAttribute 特性进行了标记,以防止从客户端将该方法作为服务调用。

      
 1         /// <summary>
 2 
 3         /// 判断是否存在相同的应用名称
 4         /// </summary>
 5         /// <param name="name"></param>
 6         /// <returns></returns>
 7         [Ignore]
 8         public bool isExist(string name)
 9         {
10             var temp = this.ObjectContext.BSMG_T_Content.Where(c => c.Name == name).OrderByDescending(c => c.ID).FirstOrDefault();
11             return temp == null ? false : true;
12         } 
13         /// <summary>
14         /// 添加应用
15 
16         /// </summary>
17         /// <param name="bSMG_T_Content"></param>
18         public void InsertBSMG_T_Content(BSMG_T_Content bSMG_T_Content)
19         {
20             if (!this.isExist(bSMG_T_Content.Name))//调用isExist()方法
21             {
22                 if ((bSMG_T_Content.EntityState != EntityState.Detached))
23                 {
24                     this.ObjectContext.ObjectStateManager.ChangeObjectState(bSMG_T_Content, EntityState.Added);
25                 }
26                 else
27                 {
28                     this.ObjectContext.BSMG_T_Content.AddObject(bSMG_T_Content);
29                 }
30             }
31         }

相关文章:

  • 2022-12-23
  • 2021-12-02
  • 2021-11-07
  • 2022-12-23
  • 2021-11-22
  • 2022-02-28
  • 2021-07-16
  • 2021-07-03
猜你喜欢
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2021-07-12
  • 2022-12-23
  • 2021-12-18
  • 2021-06-19
相关资源
相似解决方案