• 根据数据库字段类型返回c#类型函数


    <%@ 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;
      }
     
  • 相关阅读:
    memcached在大负载高并发网站上的应用(转)
    NHibernate in Action(序,前言,致谢)
    php 数据类型
    w3wp 备忘录
    EF实例化Context
    爬虫程序判断是否已抓URL
    NHibenate in Action(目录)
    C#中静态构造函数的学习
    webservice 无法在网页中进行测试问题
    汉诺塔问题C#
  • 原文地址:https://www.cnblogs.com/hhq80/p/994098.html
Copyright © 2020-2023  润新知