zoukankan      html  css  js  c++  java
  • 根据数据库字段类型返回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;
      }
     
  • 相关阅读:
    python笔记26(正则表达式、re模块)
    python笔记24(回顾、复习)
    python笔记25(正则表达式课程一)
    python笔记23(面向对象课程五)
    python(leetcode)-1.两数之和
    python(leetcode)-283移动零
    python(leetcode)-66加一问题
    python(leetcode)-350两个数组的交集
    python(leetcode)-136只出现一次的数字
    python数据结构-数组/列表/栈/队列及实现
  • 原文地址:https://www.cnblogs.com/hhq80/p/994098.html
Copyright © 2011-2022 走看看