Files
2017-09-27 10:52:50 +08:00

47 lines
1.9 KiB
Plaintext

<%@ Template Language="C#" TargetLanguage="C#" Debug="True" Encoding="UTF-8" %>
<%@ Assembly Src="..\..\Common\Model.cs" %>
<%@ Assembly Src="..\..\Common\Extensions.cs" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Text.RegularExpressions" %>
<%@ Import Namespace="SchemaMapper" %>
<%@ Property Name="Entity" Type="SchemaMapper.Entity" %>
<%@ Property Name="Namespace" Type="System.String" %>
<%-- Safe类名 --%>
<% string SafeClassName = Entity.ClassName.ToSafeName(); %>
<%-- 描述 --%>
<% string Description = Entity.Description; %>
using System;
using <%= Entity.GetNamespace(Namespace,"Domains","Models") %>;
namespace <%= Entity.GetNamespace(Namespace,"Domains","Factories") %> {
/// <summary>
/// <%= Description %>工厂
/// </summary>
public static class <%= SafeClassName %>Factory {
/// <summary>
/// 创建<%= Description %>
/// </summary>
<% foreach(Property p in Entity.Properties) { %>
/// <param name="<%= p.PropertyName.ToSafeName().ToCamelCase() %>"><%= p.Description %></param>
<%} %>
public static <%= SafeClassName %> Create(
<% foreach(Property p in Entity.Properties) { %>
<%= p.TypeName %> <%= p.PropertyName.ToSafeName().ToCamelCase() %><%= Entity.GetComma(p,false) %>
<%} %>
) {
<%= SafeClassName %> result;
<% foreach(Property p in Entity.Properties) { %>
<% if( p.IsPrimaryKey.SafeValue() ) {%>
result = new <%= SafeClassName %>( <%= p.PropertyName.ToSafeName().ToCamelCase() %> );
<% continue;} %>
result.<%= p.PropertyName.ToSafeName() %> = <%= p.PropertyName.ToSafeName().ToCamelCase() %>;
<%} %>
return result;
}
}
}