zoukankan      html  css  js  c++  java
  • XAF 如何使用复合主键和复合外键

    http://community.devexpress.com/forums/p/60725/205569.aspx

    http://www1.devexpress.com/Support/Center/p/B39252.aspx

    代码:

    [DefaultClassOptions]
        
    public class Master : XPCustomObject
        {
            
    public Master(Session session)
                : 
    base(session)
            {
                
    // This constructor is used when an object is loaded from a persistent storage.
                
    // Do not place any code here or place it only when the IsLoading property is false:
                
    // if (!IsLoading){
                
    //    It is now OK to place your initialization code here.
                
    // }
                
    // or as an alternative, move your initialization code into the AfterConstruction method.
            }
            
    public override void AfterConstruction()
            {
                
    base.AfterConstruction();
                
    // Place here your initialization code.
            }

            
    private string _MasterName;
            
    public string MasterName
            {
                
    get
                {
                    
    return _MasterName;
                }
                
    set
                {
                    SetPropertyValue(
    "MasterName"ref _MasterName, value);
                }
            }

            [Association(
    "Master-Details")]
            
    public XPCollection<Detail> Details
            {
                
    get
                {
                    
    return GetCollection<Detail>("Details");
                }
            }

            
    private MasterPrimaryKey _Key;
            [Key,Persistent,Browsable(
    false)]
            
    public MasterPrimaryKey Key
            {
                
    get
                {
                    
    return _Key;
                }
                
    set
                {
                    SetPropertyValue(
    "Key"ref _Key, value);
                }
            }

            [NonPersistent]
            
    public string Key1
            {
                
    get { return Key.Key1; }
                
    set
                {
                    _Key.Key1 
    = value;
                }
            }
            [NonPersistent]
            
    public string Key2
            {
                
    get { return Key.Key2; }
                
    set
                {
                    _Key.Key2 
    = value;
                }
            }
            
        }

        
    public struct MasterPrimaryKey
        {
            [Persistent]
            
    public string Key1;
            [Persistent]
            
    public string Key2;
        }

      
    public class Detail : XPCustomObject
        {
            
    public Detail(Session session)
                : 
    base(session)
            {
                
    // This constructor is used when an object is loaded from a persistent storage.
                
    // Do not place any code here or place it only when the IsLoading property is false:
                
    // if (!IsLoading){
                
    //    It is now OK to place your initialization code here.
                
    // }
                
    // or as an alternative, move your initialization code into the AfterConstruction method.
            }
            
    public override void AfterConstruction()
            {
                
    base.AfterConstruction();
                
    // Place here your initialization code.
            }

            
    private int _ID;
            [Key(AutoGenerate 
    = true)]
            
    public int ID
            {
                
    get
                {
                    
    return _ID;
                }
                
    set
                {
                    SetPropertyValue(
    "ID"ref _ID, value);
                }
            }

            
    private string _DetailName;
            
    public string DetailName
            {
                
    get
                {
                    
    return _DetailName;
                }
                
    set
                {
                    SetPropertyValue(
    "DetailName"ref _DetailName, value);
                }
            }

            
    private Master _Master;
            [Association(
    "Master-Details")]
            
    public Master Master
            {
                
    get
                {
                    
    return _Master;
                }
                
    set
                {
                    SetPropertyValue(
    "Master"ref _Master, value);
                }
            }
        }

     欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/

    欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/

  • 相关阅读:
    C#GridViewExport帮助类,美化导出
    C#EXCEL 操作类--C#DataToExcel帮助类
    C#EXCEL 操作类--C#ExcelHelper操作类
    VS2010 项目引用了DLL文件,也写了Using,但是编译时提示:未能找到类型或命名空间名称 <转>
    FPGA Verilog HDL 系列实例--------步进电机驱动控制
    C++使用VARIANT实现二维数组的操作
    VS2010+VMWare8+VisualDDK1.5.6 创建并调试你的第一个驱动程序
    USB编程研究之二(常见设备类型的GUID)
    C++——CString用法大全
    C++ 如何有效地使用对话框
  • 原文地址:https://www.cnblogs.com/Tonyyang/p/1912757.html
Copyright © 2011-2022 走看看