OEA体验 :常用功能2

一、摘要

       我下面写的是我在使用OEA中用到的功能,当然还有好多现在还没有用到,希望高手们多多指点指点。

OEA 源码:OEA框架 2.9 Pre-Alpha 源码公布 可以到BloodyAngel 的博客和中可以下到。

虽然作者的DEMO应经有了,但毕竟是写好的,只有自己动手才能更好的掌握这个框架,所谓体验决定深度嘛。

二、本文大纲

       a、摘要 。

       b、DDD 之父子关系 。

二、DDD 之父子关系

       DDD思想可以查考周哥的DDD - 使用聚合(Aggregate)来设计类库文章这里就不详述了。

我们要实现的效果是:

image

在这里我们还是要用到 小区表 和 客户表 哦 小区表是父 客户表是子

父(RootEntity):下面的代码有 OEAPropertyChildren 生成。

 1:  ///<summary>

    
 2:  ///描è述? : 街?道à小?区?.

    
 3:  ///<see>类à库a对?应|的?数y据Y库a表í NT_Clcs_Village </see>

    
 4:  ///</summary>

    
 5:  [Serializable]

    
 6:  [RootEntity]

    
 7:  public class Village : DemoEntity

    
 8:  {

    
 9:   

    
10:      public static readonly Property<ClientinfoList> ClientinfoListProperty = P<Village>.Register(e => e.ClientinfoList);

    
11:      [Association]

    
12:      public ClientinfoList ClientinfoList

    
13:      {

    
14:          get { return this.GetLazyChildren(ClientinfoListProperty); }

    
15:      }

    
16:   }
  

子(ChildEntity):下面的代码有 OEAPropertyReference 生成外键关系。

 1:  ///<summary>

    
 2:  ///描è述? : 客í户§信?息¢.

    
 3:  ///<see>类à库a对?应|的?数y据Y库a表í NT_Clcs_ClientInfo </see>

    
 4:  ///</summary>

    
 5:  [Serializable]

    
 6:  [ChildEntity]

    
 7:  public class Clientinfo : DemoEntity

    
 8:  {

    
 9:      public static readonly RefProperty<Village> VillageRefProperty =

    
10:          P<Clientinfo>.RegisterRef(e => e.Village, ReferenceType.Parent);

    
11:      public int VillageId

    
12:      {

    
13:          get { return this.GetRefId(VillageRefProperty); }

    
14:          set { this.SetRefId(VillageRefProperty, value); }

    
15:      }

    
16:      public Village Village

    
17:      {

    
18:          get { return this.GetRefEntity(VillageRefProperty); }

    
19:          set { this.SetRefEntity(VillageRefProperty, value); }

    
20:      }

    
21:   }
  

注意:

 1:  internal class ClientinfoConfig : EntityConfig<Clientinfo>

    
 2:  {

    
 3:      protected override void ConfigView()

    
 4:      {

    
 5:          base.ConfigView();

    
 6:   

    
 7:          View.HasLabel("客户"); // 主要要加上这个哦,要不然系统会报警的。

    
 8:      }

    
 9:   

    
10:  }

    
11:  
  

映射表:

 1:  internal class ClientinfoConfig : EntityConfig<Clientinfo>

    
 2:  {

    
 3:      protected override void ConfigMeta()

    
 4:      {

    
 5:          base.ConfigMeta();

    
 6:   

    
 7:          Meta.MapTable().HasColumns(

    
11:              HouseHold.VillageRefProperty,

    
13:              );

    
14:      }

    
15:   }
  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值