zoukankan      html  css  js  c++  java
  • OEA体验 :常用功能1

    一、摘要

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

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

    二、本文大纲

           a、摘要。

           b、数据过滤。

           c、托管属性。

           d、支持树型实体 。

    二、数据过滤

    数据查询是一个在平常不过的事,我们来看看OEA是怎么帮我们实现的。下面用一个简单的例子来说明,如我们要实现根据客户名称来查询,效果图如下:

    image

    要达到上面效果实现代码如下:

    前台调用如下:

     1:  internal class ClientinfoConfig : EntityConfig<Clientinfo>
     2:  {
     3:      protected override void ConfigMeta()
     4:      {
     5:          base.ConfigMeta();
     6:      }
     7:      protected override void ConfigView()
     8:      {
     9:          base.ConfigView();
    10:          View.UseWPFCommands("CLCS.WPF.ClientinfoSearchCommand");
    11:      }
    12:  }
    13:   

    具体代码如下:

     1:  using OEA.WPF.Command;
     2:  using OEA.MetaModel.Attributes;
     3:  using OEA.Module.WPF;
     4:  using OEA.Module.WPF.CommandAutoUI;
     5:  using OEA.MetaModel.View;
     6:   
     7:  namespace CLCS.WPF
     8:  {
     9:      [Command(Label = "过滤客户名称", UIAlgorithm = typeof(GenericItemAlgorithm<TextBoxButtonItemGenerator>))]
    10:      public class ClientinfoSearchCommand : ListViewCommand
    11:      {
    12:          public override void Execute(ListObjectView view)
    13:          {
    14:              var txt = this.TryGetCustomParams<string>(CommandCustomParams.TextBox);
                     // 设置查询条件
    15:              view.Filter = e => (e as Clientinfo).CcName.Contains(txt);
    16:          }
    17:      }
    18:  }
    19:   
    20:   
    21:   
    二、托管属性(代码生成 OEAPropertyReference )

    数据关联也是一个很平常的了,向下面的以前要写好多代码现在还不到10行就可以了。

    image

    在这需要用 小区表,和客户表  两个表

    DemoEntity 类可以在OEA体验 :元数据编写中找到

    下面的代码可以使用OEAPropertyReference 来生成

     1:  ///<summary>
     2:  ///描è述? : 客í户§信?息¢.
     3:  ///<see>类à库a对?应|的?数y据Y库a表í NT_Clcs_ClientInfo </see>
     4:  ///</summary>
     5:  [Serializable]
     6:  [RootEntity]
     7:  public class Clientinfo : DemoEntity
     8:  {
     9:      protected Clientinfo() { }
    10:      public static readonly RefProperty<Village> VillageRefProperty =
    11:          P<Clientinfo>.RegisterRef(e => e.Village, ReferenceType.Normal);
    12:      public int VillageId
    13:      {
    14:          get { return this.GetRefId(VillageRefProperty); }
    15:          set { this.SetRefId(VillageRefProperty, value); }
    16:      }
    17:      public Village Village
    18:      {
    19:          get { return this.GetRefEntity(VillageRefProperty); }
    20:          set { this.SetRefEntity(VillageRefProperty, value); }
    21:      }
    22:      #endregion
    23:  }
    24:   

    下面的是小区表的配置类

     1:  internal class VillageConfig : EntityConfig<Village>
     2:     {
     3:         protected override void ConfigMeta()
     4:         {
     5:             base.ConfigMeta();
     6:   
     7:             Meta.MapTable().HasColumns(
     8:             Village.ParentidProperty,
     9:             Village.CvNameProperty,
    10:             Village.CvPinyiProperty,
    11:             Village.CvTypeProperty,
    12:             Village.CvHeatingplantProperty,
    13:             Village.CvHscuProperty,
    14:             Village.BustypeProperty,
    15:             Village.ClientcountProperty
    16:                 );
    17:   
    18:         }
    19:         protected override void ConfigView()
    20:         {
    21:             base.ConfigView();
    22:   
    23:             View.HasTitle(Village.CvNameProperty).HasLabel("小?区?名?称?");
    24:             View.Property(Village.CvNameProperty).HasLabel("小?区?名?称?").ShowIn(ShowInWhere.List | ShowInWhere.Lookup);
    25:    }

    自动生成数据库关联关系

    image

    三、支持树型实体(代码生成 OEATreeEntity )

           向小区下面还有楼栋和单元,我们看OEA如何实现

    image

    生成的代码如下:

     1:  #region 支§持?树÷型í实μ体?
     2:   
     3:          public static readonly Property<string> TreeCodeProperty = P<Village>.Register(e => e.TreeCode);
     4:          [Column]
     5:          public override string TreeCode
     6:          {
     7:              get { return GetProperty(TreeCodeProperty); }
     8:              set { SetProperty(TreeCodeProperty, value); }
     9:          }
    10:   
    11:          public static readonly Property<int?> TreePIdProperty = P<Village>.Register(e => e.TreePId);
    12:          [Column]
    13:          public override int? TreePId
    14:          {
    15:              get { return this.GetProperty(TreePIdProperty); }
    16:              set { this.SetProperty(TreePIdProperty, value); }
    17:          }
    18:   
    19:          public override bool SupportTree { get { return true; } }
    20:   
    21:          #endregion
    22:  

    自动生成数据库关联关系

    image

    是不是很简单

  • 相关阅读:
    Android基础知识之拼写检查框架
    Android USB配件模式
    Android基础知识之Manifest中的Intent-filter元素
    如何使Android应用支持多种屏幕分辨率
    优惠券系统设计(系统设计设计篇)
    优惠券系统设计(数据库设计篇)
    优惠券系统设计(产品设计篇)
    java 文件断点续传实现原理
    java sleep和wait的区别的疑惑?
    java中的中断Thread.interrupt()意味着什么?
  • 原文地址:https://www.cnblogs.com/luomingui/p/2436105.html
Copyright © 2011-2022 走看看