好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

OEA体验:常用功能3 多对多关系

OEA体验:常用功能3 多对多关系

OEA体验:常用功能3 多对多关系

 

一、摘要

       在这里主要是写OEA设计方面的知识了。OEA 源码: OEA框架 2.9 Pre-Alpha 源码公布

可以到 BloodyAngel 的博客和中可以下到。虽然现在应经知道使用了,但是还是 需要了解框架相关知识运行机制,让我们更好的使用OEA进行开发。

二、本文大纲

       a、摘要 。

       b、UML图 (业务逻辑梳理,和父子关系的) 。

       c、项目结构,效果图  。

       d、OEA实现方法  。

三、UML图

这个图,我可是求高手求了好久才教我的 嘻嘻。

热点: 网关  设备 用户 小区

他们的关系是:

        网关下面有多个设备

        小区下面有多个用户

       用户下面有多个设备

       设备下面有多个 用户

他们的类图如下:

象下面这个图里面有个多对多,我们需要把它简化为这样的:这个是OEA提倡的分解关系

要用到OEA的外键,父子,界面扩展命令。

四、项目结构,效果图

  项目结构图:

      对应的数据库结构:

   效果图:

五、OEA实现方法

关联表的代码也是主代码了

  下面的代码主要是完成这个图啦

  1:    // 设备 用户 关联表 
  2:   [ ChildEntity ,  Serializable ]
  3:    public class   UDAssociation  :  MyEntity 
  4:   {
  5:        public static readonly   RefProperty < Device > DeviceRefProperty =
  6:            P < UDAssociation >.RegisterRef(e => e.Device,  ReferenceType . Normal );
  7:        public int  DeviceId
  8:       {
  9:            get  {  return this .GetRefId(DeviceRefProperty); }
 10:            set  {  this .SetRefId(DeviceRefProperty,  value ); }
 11:       }
 12:        public   Device  Device
 13:       {
 14:            get  {  return this .GetRefEntity(DeviceRefProperty); }
 15:            set  {  this .SetRefEntity(DeviceRefProperty,  value ); }
 16:       }
 17:    
 18:        public static readonly   RefProperty < HouseHold > HouseHoldRefProperty =
 19:            P < UDAssociation >.RegisterRef(e => e.HouseHold,  ReferenceType . Parent );
 20:        public int  HouseHoldId
 21:       {
 22:            get  {  return this .GetRefId(HouseHoldRefProperty); }
 23:            set  {  this .SetRefId(HouseHoldRefProperty,  value ); }
 24:       }
 25:        public   HouseHold  HouseHold
 26:       {
 27:            get  {  return this .GetRefEntity(HouseHoldRefProperty); }
 28:            set  {  this .SetRefEntity(HouseHoldRefProperty,  value ); }
 29:       }
 30:    
 31:        #region  视图属性
 32:        public static readonly   Property < string > View_CodeProperty =  P < UDAssociation >.RegisterReadOnly(e => e.View_Code, e => (e  as   UDAssociation ).GetView_Code(),  null );
 33:        public string  View_Code
 34:       {
 35:            get  {  return this .GetProperty(View_CodeProperty); }
 36:       }
 37:        private string  GetView_Code()
 38:       {
 39:            return this .Device.Id.ToString();
 40:       }
 41:    
 42:        public static readonly   Property < string > View_NameProperty =  P < UDAssociation >.RegisterReadOnly(e => e.View_Name, e => (e  as   UDAssociation ).GetView_Name(),  null );
 43:        public string  View_Name
 44:       {
 45:            get  {  return this .GetProperty(View_NameProperty); }
 46:       }
 47:        private string  GetView_Name()
 48:       {
 49:            return this .Device.Name;
 50:       }
 51:        #endregion 
 52:   
 53:   
 54:   }
 55:    

一个设备对应多个用户

  1:    // 一个设备对应多个用户 
  2:   [ ChildEntity ,  Serializable ]
  3:    public class   UDHouseHold  :  MyEntity 
  4:   {
  5:        public static readonly   RefProperty < UDAssociation > UserDeviceRefProperty =
  6:            P < UDHouseHold >.RegisterRef(e => e.UDAssociation,  ReferenceType . Parent );
  7:        public int  UDAssociationId
  8:       {
  9:            get  {  return this .GetRefId(UserDeviceRefProperty); }
 10:            set  {  this .SetRefId(UserDeviceRefProperty,  value ); }
 11:       }
 12:        public   UDAssociation  UDAssociation
 13:       {
 14:            get  {  return this .GetRefEntity(UserDeviceRefProperty); }
 15:            set  {  this .SetRefEntity(UserDeviceRefProperty,  value ); }
 16:       }
 17:        public static readonly   RefProperty < HouseHold > HouseHoldRefProperty =
 18:             P < UDHouseHold >.RegisterRef(e => e.HouseHold,  ReferenceType . Normal );
 19:        public int  HouseHoldId
 20:       {
 21:            get  {  return this .GetRefId(HouseHoldRefProperty); }
 22:            set  {  this .SetRefId(HouseHoldRefProperty,  value ); }
 23:       }
 24:        public   HouseHold  HouseHold
 25:       {
 26:            get  {  return this .GetRefEntity(HouseHoldRefProperty); }
 27:            set  {  this .SetRefEntity(HouseHoldRefProperty,  value ); }
 28:       }
 29:    
 30:        #region  视ó图?属?性?
 31:    
 32:        public static readonly   Property < string > View_CodeProperty =  P < UDHouseHold >.RegisterReadOnly(e => e.View_Code, e => (e  as   UDHouseHold ).GetView_Code(),  null );
 33:        public string  View_Code
 34:       {
 35:            get  {  return this .GetProperty(View_CodeProperty); }
 36:       }
 37:        private string  GetView_Code()
 38:       {
 39:            return  HouseHold.Id.ToString();
 40:       }
 41:    
 42:        public static readonly   Property < string > View_NameProperty =  P < UDHouseHold >.RegisterReadOnly(e => e.View_Name, e => (e  as   UDHouseHold ).GetView_Name(),  null );
 43:        public string  View_Name
 44:       {
 45:            get  {  return this .GetProperty(View_NameProperty); }
 46:       }
 47:        private string  GetView_Name()
 48:       {
 49:            return  HouseHold.Name;
 50:       }
 51:    
 52:        #endregion 
 53:   }
 54:    

一个用户有多个设备

  1:    // 一?个?用?户§有D多à个?设è备? 
  2:   [ ChildEntity ,  Serializable ]
  3:    public class   UDDevices  :  MyEntity 
  4:   {
  5:        public static readonly   RefProperty < UDAssociation > UDAssociationRefProperty =
  6:              P < UDDevices >.RegisterRef(e => e.UDAssociation,  ReferenceType . Parent );
  7:        public int  UDAssociationId
  8:       {
  9:            get  {  return this .GetRefId(UDAssociationRefProperty); }
 10:            set  {  this .SetRefId(UDAssociationRefProperty,  value ); }
 11:       }
 12:        public   UDAssociation  UDAssociation
 13:       {
 14:            get  {  return this .GetRefEntity(UDAssociationRefProperty); }
 15:            set  {  this .SetRefEntity(UDAssociationRefProperty,  value ); }
 16:       }
 17:        public static readonly   RefProperty < Device > DeviceRefProperty =
 18:            P < UDDevices >.RegisterRef(e => e.Device,  ReferenceType . Normal );
 19:        public int  DeviceId
 20:       {
 21:            get  {  return this .GetRefId(DeviceRefProperty); }
 22:            set  {  this .SetRefId(DeviceRefProperty,  value ); }
 23:       }
 24:        public   Device  Device
 25:       {
 26:            get  {  return this .GetRefEntity(DeviceRefProperty); }
 27:            set  {  this .SetRefEntity(DeviceRefProperty,  value ); }
 28:       }
 29:   }
 30:    

啥也不说了,直接下载源码看了。

 

作者:罗敏贵
邮箱:minguiluo@gmail.com
QQ群:34178394 建群 主要是寻找志同道合的人士一起学习和讨论自己的所学所思
出处: http://luomingui.cnblogs.com/
说明:专注于微软平台项目架构、熟悉设计模式、架构设计、敏捷个人和项目管理。现主要从事WinForm、ASP.NET、等方面的项目开发、架构、管理工作。文章为作者平时里的思考和练习,可能有不当之处,请博客园的园友们多提宝贵意见。
本作品采用 知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议 进行许可。

作者: Leo_wl

    

出处: http://www.cnblogs.com/Leo_wl/

    

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

版权信息

查看更多关于OEA体验:常用功能3 多对多关系的详细内容...

  阅读:38次