首页 > 其他 > 详细

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

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

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框架)

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!