第一个文件是businessobjctforView.cst,生成C#实体类,此脚本需要引用第二个文件CommonUtility.cs。需将两个文件放在同一目录中。
<SQL'>%@CodeTemplateLanguage="C#"TargetLanguage="T-SQL"
Description="Generatesaupdatestoredprocedure."%>
<%@AssemblyName="SchemaExplorer"%>
<%@ImportNamespace="SchemaExplorer"%>
<%@PropertyName="SourceTable"Type="SchemaExplorer.ViewSchema"
Category="Context"
Description="Tablethatthestoredproceduresshouldbebasedon."%>
<%@AssemblySrc="CommonUtility.cs"%>
<%@ImportNamespace="Common.Data"%>
<scriptrunat="template">
CommonUtilityrule=newCommonUtility();
</script>
usingSystem;
usingSystem.Collections;
usingSystem.Collections.Generic;
usingSystem.Data;
namespaceSOA.Model
{
///<summary>
///<%=SourceTable.Name%>objectforViewtable'<%=SourceTable.Name%>'.
///</summary>
[Serializable]
publicclass<%=SourceTable.Name%>
{
#regionPrivateMember
<%for(inti=0;i<SourceTable.Columns.Count;i++){%>
private<%=rule.GetCSharpVariableType(SourceTable.Columns[i])%>_<%=SourceTable.Columns[i].Name%>;
<%}%>
#endregion
#regionConstructor
public<%=SourceTable.Name%>(){}
public<%=SourceTable.Name%>(
<%for(inti=0;i<SourceTable.Columns.Count-1;i++){%>
<%=rule.GetCSharpVariableType(SourceTable.Columns[i])%><%=SourceTable.Columns[i].Name%>,
<%}%>
<%=rule.GetCSharpVariableType(SourceTable.Columns[SourceTable.Columns.Count-1])%><%=SourceTable.Columns[SourceTable.Columns.Count-1].Name%>
)
{
<%for(inti=0;i<SourceTable.Columns.Count;i++){%>
_<%=SourceTable.Columns[i].Name%>=<%=SourceTable.Columns[i].Name%>;
<%}%>
}
#endregion
#regionPublicProperties
<%for(inti=0;i<SourceTable.Columns.Count;i++){%>
public<%=rule.GetCSharpVariableType(SourceTable.Columns[i])%><%=rule.GetCamelCaseName(SourceTable.Columns[i].Name)%>
{
get{return_<%=SourceTable.Columns[i].Name%>;}
set{_<%=SourceTable.Columns[i].Name%>=value;}
}
<%}%>
#endregion
}
}