📄 table_row_base.atcs
字号:
<#--
Base TableRow template.
--##>
<#@ Imports
using System;
using System.Data.OleDb;
using TwoLKit.nTierBuilder.Api.DbDom;
##>
<#@ InstanceMembers
private ITable Table
{
get { return (ITable)Environment["Table"]; }
}
private string GetClassName()
{
return Table.CodeName + "Row_Base";
}
private string GetUserClassName()
{
return Table.CodeName + "Row";
}
public override string RelativeFilePath
{
get { return GetClassName() + ".vb"; }
}
private bool ShouldGenerateNullableProperty(IColumn column)
{
return column.Nullable && SharedUtils.ToDotNetType(column.OleDbType).IsValueType;
}
private string GetFieldName(IColumn column)
{
return SharedUtils.GetFieldName(column.CodeName);
}
private string GetParameterName(IColumn column)
{
return SharedUtils.GetParameterName(column.CodeName);
}
private string GetPropertyName(IColumn column)
{
return SharedUtils.GetPropertyName(column.CodeName);
}
private Type GetDotNetType(IColumn column)
{
return SharedUtils.GetDotNetType(column, false);
}
private string GetDotNetTypeName(IColumn column)
{
return SharedUtils.GetCSharpTypeName(GetDotNetType(column));
}
private void WriteParameterList(bool includeTypes, string indent)
{
bool firstItem = true;
foreach(IColumn column in Table.Columns)
{
if(firstItem)
firstItem = false;
else
{
Writer.WriteLine(',');
Writer.Write(indent);
}
if(includeTypes)
{
Writer.Write(GetDotNetTypeName(column));
Writer.Write(' ');
}
Writer.Write(GetParameterName(column));
}
}
private string GetNamespace()
{
return SharedUtils.GetDbTierNamespace(Table.Database);
}
##>
' <fileinfo name="<#= RelativeFilePath #>">
' <copyright owner="<#= Environment["CopyrightOwner"] #>">
' All Rights Reserved.
' </copyright>
' <remarks>
' Do not change this source code manually. Changes to this file may
' cause incorrect behavior and will be lost if the code is regenerated.
' </remarks>
' <generator rewritefile="<#= RewriteExistingFile #>" infourl="http://www.2LKit.com">2LKit nTier Builder</generator>
' <created><#= DateTime.Now.ToString("f") #></created>
' </fileinfo>
Option Strict Off
Option Explicit On
Imports System
'' <summary>
'' The base class for <#= GetUserClassName() #> that represents a '<#= Table.Name #>' record.
'' Do not change this source code. Update the <#= GetUserClassName() #> class if
'' you need to add or change some functionality.
'' </summary>
Public MustInherit Class <#= GetClassName() #>
<# foreach(IColumn column in Table.Columns)
{ ##>
Private <#= GetFieldName(column) #> As <#= GetDotNetTypeName(column)#>
<# if(ShouldGenerateNullableProperty(column))
{ ##>
Private <#= GetFieldName(column) #>Null As Boolean = True
<# } ##>
<# } ##>
'' <summary>
'' Initializes a new instance of the <#= GetClassName() #> class.
'' </summary>
Public Sub New()
MyBase.New()
' EMPTY
End Sub
<# // Write properties
foreach(IColumn column in Table.Columns)
{ ##>
'' <summary>
'' Gets or sets the '<#= column.Name #>' column value.
<# if(column.Nullable)
{ ##>
'' This column is nullable.
<# } ##>
'' </summary>
'' <value>The '<#= column.Name #>' column value.</value>
Public Property <#= GetPropertyName(column) #> As <#= GetDotNetTypeName(column)#>
<# if(ShouldGenerateNullableProperty(column))
{ ##>
Get
If Is<#= GetPropertyName(column) #>Null Then
Throw New InvalidOperationException("Cannot get value because it is DBNull.")
End If
Return <#= GetFieldName(column) #>
End Get
Set
<#= GetFieldName(column) #>Null = false
<#= GetFieldName(column) #> = value
End Set
<# }
else
{ ##>
Get
Return <#= GetFieldName(column) #>
End Get
Set
<#= GetFieldName(column) #> = value
End Set
<# } ##>
End Property
<# if(ShouldGenerateNullableProperty(column))
{ ##>
'' <summary>
'' Indicates whether or not the <#= GetPropertyName(column) #> value is null.
'' </summary>
'' <value>true if the property is null, otherwise false.</value>
Public Property Is<#= GetPropertyName(column) #>Null As Boolean
Get
Return <#= GetFieldName(column) #>Null
End Get
Set
<#= GetFieldName(column) #>Null = value
End Set
End Property
<# } // end if column.Nullable ##>
<# } ##>
'' <summary>
'' Returns the string representation of this instance.
'' </summary>
'' <returns>The string representation of this instance.</returns>
Public Overrides Function ToString() As String
Dim dynStr As System.Text.StringBuilder = New System.Text.StringBuilder(Me.GetType().Name)
dynStr.Append(":")
<# foreach(IColumn column in Table.Columns)
{
if(!GetDotNetType(column).IsArray)
{ ##>
dynStr.Append(" <#= GetPropertyName(column) #>=")
<# if(ShouldGenerateNullableProperty(column))
{ ##>
If Is<#= GetPropertyName(column) #>Null Then
dynStr.Append("<NULL>")
Else
dynStr.Append(<#= GetPropertyName(column) #>)
End If
<# }
else
{ ##>
dynStr.Append(<#= GetPropertyName(column) #>)
<# }
}
}
##>
Return dynStr.ToString()
End Function
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -