<%@ CodeTemplate Language="C#" TargetLanguage="T-SQL" ResponseEncoding="UTF-8" Src="" Inherits="" Debug="False" Description="Template description here." %>
<%@ Property Name="ProcedureName" Type="String" Default="" Optional="False" Category="" Description=""%>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Default="" Optional="False" Category="" Description=""%>
<script runat="template">
public string GetCSharpVariableType(ColumnSchema column)
{
if (column.Name.EndsWith("TypeCode")) return column.Name;
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.Guid: return "Guid";
case DbType.Int16: return "short";
case DbType.Int32: return "int";
case DbType.Int64: return "long";
case DbType.Object: return "object";
case DbType.SByte: return "sbyte";
case DbType.Single: return "float";
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";
default:
{
return "__UNKNOWN__" + column.NativeType;
}
}
}
</script>
public static long Insert_<%=SourceTable.Name%>(<%for(int i=0;i<SourceTable.Columns.Count;i++){%><%=GetCSharpVariableType(SourceTable.Columns[i])%> <%=SourceTable.Columns[i].Name%><%if(i<SourceTable.Columns.Count-1){%>,<%}%><%}%>)
{
long InfoStatus=-101;
InfoStatus = Convert.ToInt32(SqlHelper.ExecuteScalar(ConfigurationSettings.AppSettings["connString"], "<%=ProcedureName%>",<%for(int i=0;i<SourceTable.Columns.Count;i++){%><%=SourceTable.Columns[i].Name%><%if(i<SourceTable.Columns.Count-1){%>,<%}%><%}%>));
return InfoStatus;
}