码迷,mamicode.com
首页 > 其他好文 > 详细

动软软件 生成 实体类模板(EnterpriseFrameWork框架)

时间:2017-06-01 17:55:27      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:为什么   tput   framework   hosts   pre   .so   type   summary   codec   

1.废话不多说,直接上效果图 。

技术分享

2 .动软模板代码

技术分享
<#@ template language="c#" HostSpecific="True" #>
<#@ output extension= ".cs" #>
<#
    TableHost host = (TableHost)(Host);
    host.Fieldlist.Sort(CodeCommon.CompareByintOrder);
#>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EFWCoreLib.CoreFrame.Orm;
using EFWCoreLib.CoreFrame.Business;
namespace Cloud.Code.Entity<# if( host.Folder.Length > 0) {#>.<#= host.Folder #><# } #>
{
    <# if( host.TableDescription.Length > 0) {#>
     //<#= host.TableDescription #>
    <# } #>
  [Serializable]
   [Table(TableName = "<#= host.GetModelClass(host.TableName) #>", EntityType = EntityType.Table, IsGB = true)]
 
   public class <#= host.GetModelClass(host.TableName) #> :AbstractEntity
    {  
        #region 自動生成
          <# foreach (ColumnInfo c in host.Fieldlist)
        { #>
        /// <summary>
        /// <#= string.IsNullOrEmpty(c.Description) ? c.ColumnName : c.Description #>
        /// </summary>      
        <# if(c.IsIdentity) {#>
           [Column(FieldName = "<#= c.ColumnName #>", DataKey = false,  Match = "", IsInsert = fasle)]
         <# } else {#>        
           [Column(FieldName = "<#= c.ColumnName #>", DataKey = false,  Match = "", IsInsert = true)]
          <# } #>
        public <#= CodeCommon.DbTypeToCS(c.TypeName) #> <#= c.ColumnName #> { get; set ;}  
        <# } #>
      #endregion
   
    }
}
实体类

3.为什么推荐此 ORM 实体类。因为在 实际的 工作中,参与过一项过万级的项目,当时是配有专门的DB人员。其中数据库表 及 表的字段 含有 中文,当初百思不得其解,最后得到的回复是 老板要求,o(╯□╰)o

 

动软软件 生成 实体类模板(EnterpriseFrameWork框架)

标签:为什么   tput   framework   hosts   pre   .so   type   summary   codec   

原文地址:http://www.cnblogs.com/chuangjie1988/p/6929783.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!