Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions AutoGenDOTemplate.cst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using System.Text;
namespace <%=NameSpace%>
{
[Table("<%=SourceTable.Name %>")]
public class <%=GetClassName(SourceTable)+"DO" %>
public class <%=GetClassName(SourceTable) %>
{
<% foreach (ColumnSchema column in SourceTable.Columns) {%>
/// <summary>
Expand Down Expand Up @@ -110,39 +110,41 @@ public string GetPrimaryKeyType(TableSchema table)
public string GetCSharpVariableType(ColumnSchema column)
{
if (column.Name.EndsWith("TypeCode")) return column.Name;

var allowDBNullString = column.AllowDBNull ? "?":"";

switch (column.DataType)
{
case DbType.AnsiString: return "string";
case DbType.AnsiStringFixedLength: return "string";
case DbType.Binary: return "byte[]";
case DbType.Boolean: return "bool";
case DbType.Byte: return "byte";
case DbType.Currency: return "decimal";
case DbType.Date: return "DateTime";
case DbType.DateTime: return "DateTime";
case DbType.Decimal: return "decimal";
case DbType.Double: return "double";
case DbType.Boolean: return "bool" + allowDBNullString;
case DbType.Byte: return "byte" + allowDBNullString;
case DbType.Currency: return "decimal" + allowDBNullString;
case DbType.Date: return "DateTime" + allowDBNullString;
case DbType.DateTime: return "DateTime" + allowDBNullString;
case DbType.Decimal: return "decimal" + allowDBNullString;
case DbType.Double: return "double" + allowDBNullString;
case DbType.Guid: return "Guid";
case DbType.Int16: return "short";
case DbType.Int32: return "int";
case DbType.Int64: return "long";
case DbType.Int16: return "short" + allowDBNullString;
case DbType.Int32: return "int" + allowDBNullString;
case DbType.Int64: return "long" + allowDBNullString;
case DbType.Object: return "object";
case DbType.SByte: return "sbyte";
case DbType.Single: return "float";
case DbType.SByte: return "sbyte" + allowDBNullString;
case DbType.Single: return "float" + allowDBNullString;
case DbType.String: return "string";
case DbType.StringFixedLength: return "string";
case DbType.Time: return "TimeSpan";
case DbType.UInt16: return "ushort";
case DbType.UInt32: return "uint";
case DbType.UInt64: return "ulong";
case DbType.VarNumeric: return "decimal";
case DbType.Time: return "TimeSpan" + allowDBNullString;
case DbType.UInt16: return "ushort" + allowDBNullString;
case DbType.UInt32: return "uint" + allowDBNullString;
case DbType.UInt64: return "ulong" + allowDBNullString;
case DbType.VarNumeric: return "decimal" + allowDBNullString;
default:
{
return "__UNKNOWN__" + column.NativeType;
return "__UNKNOWN__" + column.NativeType + allowDBNullString;
}
}
}

public override string GetFileName()
{
return GetClassName(SourceTable) + ".cs";
Expand Down