zoukankan      html  css  js  c++  java
  • OEA框架学习:使用动软代码生成器

    一、摘要

            没事玩玩,哈。有感兴趣的可以去玩玩。

    二、本文大纲

           a、摘要  。

           b、动软介绍 。

           c、动软模板  。

    三、动软介绍

     

    大家直接去看官网就可以了哈,地址了,在这呢。http://www.maticsoft.com/default.htm 

      image

       这里就不细说了吧。

          

    四、动软模板

          OEA实体模板。

     1:  <#@ template language="c#" HostSpecific="True" #>
     2:  <#@ output extension= ".cs" #>
     3:  <#
     4:      TableHost host = (TableHost)(Host);
     5:      host.Fieldlist.Sort(CodeCommon.CompareByintOrder);
     6:  #>
     7:  using System;
     8:  using System.Collections.Generic;
     9:  using System.Linq;
    10:  using System.Text;
    11:  using OEA.Library;
    12:  using OEA.MetaModel;
    13:  using OEA.MetaModel.Attributes;
    14:  using OEA.MetaModel.View;
    15:  
    16:  namespace  <#= host.NameSpace #> 
    17:  {
    18:      <# if( host.TableDescription.Length > 0) {#>
    19:      //<#= host.TableDescription #>
    20:      <# } #>
    21:      [RootEntity, Serializable]
    22:      public class <#= host.GetModelClass(host.TableName) #> : MyEntity
    23:      {
    24:         <# foreach (ColumnInfo c in host.Fieldlist)
    25:          { #>/// <summary>
    26:          /// <#= string.IsNullOrEmpty(c.Description)  ? c.ColumnName : c.Description #>
    27:          /// </summary>        
    28:          public static readonly Property<<#= CodeCommon.DbTypeToCS(c.TypeName) #>> <#= c.ColumnName #>Property = P<<#= host.GetModelClass(host.TableName) #>>.Register(e => e.<#= c.ColumnName #>);
    29:          public <#= CodeCommon.DbTypeToCS(c.TypeName) #> <#= c.ColumnName #>
    30:          {
    31:              get { return this.GetProperty(<#= c.ColumnName #>Property); }
    32:              set { this.SetProperty(<#= c.ColumnName #>Property, value); }
    33:          }        
    34:          <# } #> 
    35:      }
    36:  
    37:      [Serializable]
    38:      public class <#= host.GetModelClass(host.TableName) #>List : MyEntityList
    39:      {
    40:          public <#= host.GetModelClass(host.TableName) #>List()
    41:          {
    42:  
    43:          }     
    44:      }
    45:  
    46:      public class <#= host.GetModelClass(host.TableName) #>Repository : EntityRepository
    47:      {
    48:          protected <#= host.GetModelClass(host.TableName) #>Repository() { }
    49:      }
    50:  
    51:      internal class <#= host.GetModelClass(host.TableName) #>Config : EntityConfig<<#= host.GetModelClass(host.TableName) #>>
    52:      {
    53:          protected override void ConfigMeta()
    54:          {
    55:              base.ConfigMeta();
    56:  
    57:              Meta.MapAllPropertiesToTable();
    58:              
    59:              //基础数据启用分布式缓存
    60:              //Meta.EnableCache();
    61:          }
    62:  
    63:          protected override void ConfigView()
    64:          {
    65:              base.ConfigView();
    66:          <# foreach (ColumnInfo c in host.Fieldlist)
    67:          { #> 
    68:          View.Property(<#= host.GetModelClass(host.TableName) #>.<#= c.ColumnName #>Property).HasLabel("<#= string.IsNullOrEmpty(c.Description)  ? c.ColumnName : c.Description #>").ShowIn(ShowInWhere.All);
    69:          <# } #> 
    70:          }
    71:      }
    72:  }

    直接把上面的代码保存 *.cmt 格式的文件就可以了。

    生成出来的效果是:

      1:  using System;
      2:  using System.Collections.Generic;
      3:  using System.Linq;
      4:  using System.Text;
      5:  using OEA.Library;
      6:  using OEA.MetaModel;
      7:  using OEA.MetaModel.Attributes;
      8:  using OEA.MetaModel.View;
      9:  
     10:  namespace  Maticsoft 
     11:  {
     12:          //HeatingType
     13:          [RootEntity, Serializable]
     14:      public class HeatingType : MyEntity
     15:      {
     16:         /// <summary>
     17:          /// id
     18:          /// </summary>        
     19:          public static readonly Property<int> idProperty = P<HeatingType>.Register(e => e.id);
     20:          public int id
     21:          {
     22:              get { return this.GetProperty(idProperty); }
     23:              set { this.SetProperty(idProperty, value); }
     24:          }        
     25:          /// <summary>
     26:          /// ht_Name
     27:          /// </summary>        
     28:          public static readonly Property<string> ht_NameProperty = P<HeatingType>.Register(e => e.ht_Name);
     29:          public string ht_Name
     30:          {
     31:              get { return this.GetProperty(ht_NameProperty); }
     32:              set { this.SetProperty(ht_NameProperty, value); }
     33:          }        
    134:       }
    135:  
    136:      [Serializable]
    137:      public class HeatingType List : MyEntityList
    138:      {
    139:          public HeatingTypeList()
    140:          {
    141:  
    142:          }     
    143:      }
    144:  
    145:      public class HeatingType Repository : EntityRepository
    146:      {
    147:          protected HeatingTypeRepository() { }
    148:      }
    149:  
    150:      internal class HeatingTypeConfig : EntityConfig<HeatingType>
    151:      {
    152:          protected override void ConfigMeta()
    153:          {
    154:              base.ConfigMeta();
    155:  
    156:              Meta.MapAllPropertiesToTable();
    157:              
    158:              //基础数据启用分布式缓存
    159:              //Meta.EnableCache();
    160:          }
    161:  
    162:          protected override void ConfigView()
    163:          {
    164:              base.ConfigView();
    165:           
    166:          View.Property(HeatingType.idProperty).HasLabel("id").ShowIn(ShowInWhere.All);
    167:          
    168:          View.Property(HeatingType.ht_NameProperty).HasLabel("ht_Name").ShowIn(ShowInWhere.All);
    169:          
    192:           }
    193:      }
    194:  }
  • 相关阅读:
    poj1113--凸包(Andrew)
    php变量内存完全释放
    php的内存分配还是很智能的
    git 忽略权限记录一下
    开启事务处理插入多条数据 速度也可以
    var_dump(is_writeable(ini_get("session.save_path")));
    要注意一下xss攻击啊
    select *," as A from B union ...
    多次踩坑
    js instanceof运算符
  • 原文地址:https://www.cnblogs.com/luomingui/p/2526143.html
Copyright © 2011-2022 走看看