zoukankan      html  css  js  c++  java
  • xaf.domain object new 在属性上的用法

    有如下业务对象定义:

    using System;
    using System.Linq;
    using System.Text;
    using DevExpress.Xpo;
    using DevExpress.ExpressApp;
    using System.ComponentModel;
    using DevExpress.ExpressApp.DC;
    using DevExpress.Data.Filtering;
    using DevExpress.Persistent.Base;
    using System.Collections.Generic;
    using DevExpress.ExpressApp.Model;
    using DevExpress.Persistent.BaseImpl;
    using DevExpress.Persistent.Validation;
    
    namespace TestXPO.Module.BusinessObjects
    {
      //往来单位:供应商,客户都是此类的派生类 [XafDefaultProperty(
    "Name")] [DefaultClassOptions] public abstract class CompanyUnit : BaseObject { public CompanyUnit(Session s) : base(s) { } public string Name { get { return GetPropertyValue<string>(nameof(Name)); } set { SetPropertyValue(nameof(Name), value); } } } [DefaultClassOptions] [XafDefaultProperty(nameof(Address))] public class Customer : CompanyUnit { public Customer(Session s) : base(s) { } public string Address { get { return GetPropertyValue<string>(nameof(Address)); } set { SetPropertyValue(nameof(Address), value); } } } [DefaultClassOptions] public class Provider : CompanyUnit { public Provider(Session s) : base(s) { } } public class Dept : CompanyUnit { public Dept(Session s) : base(s) { } }
      //存在某种单据基类:
      //使用了CompanyUnit做为属性的类型
      //在派生类中new TargetUnit重新定义此属性的类型,则可以成功
      //可以达到使用真实类型过滤的作用.
      //但如果使用Guid类型声明,并且派生类中用复杂类型,则不能成功 [DefaultClassOptions]
    public class FormBase : BaseObject { public FormBase(Session session) : base(session) { } public CompanyUnit TargetUnit { get { return GetPropertyValue<CompanyUnit>(nameof(TargetUnit)); } set { SetPropertyValue(nameof(TargetUnit), value); } } } [DefaultClassOptions] public class PMSOrder : FormBase { public PMSOrder(Session s) : base(s) { } public new Provider TargetUnit { get { return GetPropertyValue<Provider>(nameof(TargetUnit)); } set { SetPropertyValue(nameof(TargetUnit), value); } } } [DefaultClassOptions] public class SMSOrder : FormBase { public SMSOrder(Session s) : base(s) { } public new Customer TargetUnit { get { return GetPropertyValue<Customer>(nameof(TargetUnit)); } set { SetPropertyValue(nameof(TargetUnit), value); } } } }
  • 相关阅读:
    [ARM] Cortex-M Startup.s启动文件相关代码解释
    [OpenCVsharp]利用指针实现高速访问像素RGB值
    Ubuntu环境下安装TinyOS系统
    win8.1环境下安装arduino驱动问题解决方案
    VMware-Transport(VMDB) error -44:Message.The VMware Authorization Service is not running解决方案
    1.Python 简单输入输出
    HTML速查列表
    Linux安装svn
    CentOS7系统操作httpd服务
    CentOS 7 防火墙端口配置
  • 原文地址:https://www.cnblogs.com/foreachlife/p/xaf_new_property.html
Copyright © 2011-2022 走看看