动软代码生成与 EntityFramework 实体生成模板
有用到EntityFrameWork的同学们,可以用用。
实体工程中添加EF6的dll
还有
ValidBox4Mvc.ValidRules.dll应用到项目中,此dll下载地址:http://www.cnblogs.com/kewei/p/3548517.html
<#@ template language="c#" HostSpecific="True" #>
<#@ output extension= ".cs" #>
<#
TableHost host = (TableHost)(Host);
host.Fieldlist.Sort(CodeCommon.CompareByintOrder);
#>
using System;
using System.Text;
using System.Collections.Generic;
using EF=System.ComponentModel.DataAnnotations.Schema;
using EFKey=System.ComponentModel.DataAnnotations;
using ValidBox4Mvc.ValidRules;
namespace TC.Cloud.Public.Model
{
<# if( host.TableDescription.Length > 0) {#> /// <summary>
///<#= host.TableDescription #>
/// </summary>
[Serializable]
[EF.Table("<#= host.GetModelClass(host.TableName) #>")]
<# } #>
public class <#=System.Text.RegularExpressions.Regex.Replace(host.GetModelClass(host.TableName), @"^.*?_", "") #>
{ <# foreach (ColumnInfo c in host.Fieldlist)
{ #>/// <summary>
/// <#= string.IsNullOrEmpty(c.Description) ? c.ColumnName : c.Description #>
/// </summary>
<# if (c.IsPrimaryKey) {#>[EFKey.Key]<#}#>
<# if (c.TypeName =="varchar") {#>[Length(<#=Convert.ToInt32(c.Length)/2 #>)]<#} if (c.TypeName =="nvarchar") {#> [Length(<#=c.Length #>)]<#}#>
<# if (!c.Nullable) {#>[Required(ErrorMessage = "<#= string.IsNullOrEmpty(c.Description) ? c.ColumnName : c.Description #>不能为空")]<#}#>
[EF.Column("<#= c.ColumnName #>")]
public <#= CodeCommon.DbTypeToCS(c.TypeName) #> <#=System.Text.RegularExpressions.Regex.Replace(c.ColumnName, @"^.*?_", "") #>{ get;set; }
<# } #> }
}
不带验证的
<#@ template language="c#" HostSpecific="True" #>
<#@ output extension= ".cs" #>
<#
TableHost host = (TableHost)(Host);
host.Fieldlist.Sort(CodeCommon.CompareByintOrder);
#>
using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
namespace <#= host.NameSpace #>.Model<# if( host.Folder.Length > ) {#>.<#= host.Folder #><# } #>
{
<# if( host.TableDescription.Length > ) {#>
//<#= host.TableDescription #>
<# } #>
public class <#= host.GetModelClass(host.TableName) #>
{ <# foreach (ColumnInfo c in host.Fieldlist)
{ #>/// <summary>
/// <#= string.IsNullOrEmpty(c.Description) ? c.ColumnName : c.Description #>
/// </summary>
[Display(Name = "<#= string.IsNullOrEmpty(c.Description) ? c.ColumnName : c.Description #>")]
public <#= CodeCommon.DbTypeToCS(c.TypeName) #> <#= c.ColumnName #>
{
get;
set;
}
<# } #> public <#= host.GetModelClass(host.TableName) #>(<# int i=; foreach (ColumnInfo c in host.Fieldlist) { #><#=CodeCommon.DbTypeToCS(c.TypeName) #> _<#= c.ColumnName #><# if(i!=host.Fieldlist.Count) { #>,<# }#> <# i++; } #>)
{ <#foreach(ColumnInfo c in host.Fieldlist) { #>
this.<#= c.ColumnName#>= _<#= c.ColumnName#>;<# } #>
} public <#= host.GetModelClass(host.TableName) #>(){} }
}
vs2013批量删除空行 :^\s\S*$\n
动软代码生成与 EntityFramework 实体生成模板的更多相关文章
- 动软代码生成V2.74模版简介
最近发现很多人用动软代码生成,确实方便,有些经验记录下,以后查看回顾. ..\Maticsoft\Codematic2\Template\TemplateFile 为模板文件夹,直接在目录下新建文件夹 ...
- 手把手教你用动软.NET代码生成器实例教程
动软实战攻略 手把手教你用动软 文档编号:20110421 版权所有 © 2004-2011 动软 在线帮助:http://help.maticsoft.com 目录 一. 产品介绍 ...
- asp.net+mvc+easyui+sqlite 简单用户系统学习之旅(三)—— 简单登录页面+sqlite+动软代码生成器的使用
上一节讲到利用easyui的layout.tree.tab和datagrid创建用户管理的页面,注意利用到easyui的页面一定要按顺序添加jQuery和easyUI的.js和.css样式,灵活查看e ...
- 【动软.Net代码生成器】连接MySQL生成C#的POCO实体类(Model)
首先是工具的下载地址: 动软.Net代码生成器 该工具官网自带完整教程: 文档:http://www.maticsoft.com/help/ 例子:http://www.maticsoft.com/h ...
- 动软生成的WCP DAO层模板(不使用接口)
本实战是博主初次学习Java,分析WCP源码时,学习HibernateTools部分的实战,由于初次接触,难免错误,仅供参考,希望批评指正. 开发环境: Eclipse Version: Photon ...
- 动软软件 生成 实体类模板(EnterpriseFrameWork框架)
1.废话不多说,直接上效果图 . 2 .动软模板代码 <#@ template language="c#" HostSpecific="True" #&g ...
- 动软Model 模板 生成可空类型字段
动软代码 生成可空类型 <#@ template language="c#" HostSpecific="True" #> <#@ outpu ...
- 动软代码生成器 可用于生成Entity层,可更改模板 /codesmith 也可以
动软代码生成器官方下载地址:http://www.maticsoft.com/download.aspx 教程:http://jingyan.baidu.com/article/219f4bf7dfd ...
- C# 嵌入dll 动软代码生成器基础使用 系统缓存全解析 .NET开发中的事务处理大比拼 C#之数据类型学习 【基于EF Core的Code First模式的DotNetCore快速开发框架】完成对DB First代码生成的支持 基于EF Core的Code First模式的DotNetCore快速开发框架 【懒人有道】在asp.net core中实现程序集注入
C# 嵌入dll 在很多时候我们在生成C#exe文件时,如果在工程里调用了dll文件时,那么如果不加以处理的话在生成的exe文件运行时需要连同这个dll一起转移,相比于一个单独干净的exe,这种形 ...
随机推荐
- depth_write
Sets whether or not this pass renders with depth-buffer writing on or not. Format: depth_write <o ...
- System.Linq.Dynamic 和Nhibernate
var session = NHibernateSessionManager.Instance.GetSession(); "); var staffList = session.Query ...
- [Web前端系列之_Firebug_00_序]
[因] 以前一直把Firebug当做参考他人网站界面结构的工具,看看css,js等,没有深挖.这段时间在项目组里主要充当前台工作,也有空,就准备把前端给精通点,firebug作为入手点. [参考资料] ...
- BZOJ 3406 乳草的入侵
BFS. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm&g ...
- HDU 5335 Walk Out (BFS,技巧)
题意:有一个n*m的矩阵,每个格子中有一个数字,或为0,或为1.有个人要从(1,1)到达(n,m),要求所走过的格子中的数字按先后顺序串起来后,用二进制的判断大小方法,让这个数字最小.前缀0不需要输出 ...
- 使用过的Linux命令
1 在vim中编辑python,由于tab是8个空格,然而python中是4个,需要替换 :%s/\t/ /g 2 tar tar -czvf topic_dt_poi.0801.0818.ta ...
- TCP握手
1.TCP的三次握手四次挥手 第一次握手:Client将标志位SYN置为1,随机产生一个值seq=J,并将该数据包发送给Server,Client进入SYN_SENT状态,等待Server确认. 第二 ...
- [转]就这样,创建了自己的运行时共享库(RSL)
原文地址:http://riaoo.com/?p=1405 博客园的下载地址(版权归原作者) http://files.cnblogs.com/tianlanliao/CustomRSL.zip 创建 ...
- PL/SQL 下邮件发送程序
对DBA而言,尽管在os级别下发送邮件是轻而易举的事情,然而很多时候我们也需要在PL/SQL中来发送邮件,比如监控job的执行状况等.本文根据网友(源作者未考证)的代码将其改装并封装到了package ...
- android EditText控件可输入正负数及小数位
设置android:inputType="numberSigned|numberDecimal" <EditText android:id="@+id/editTe ...