用codesmith能否產生訪問oracle的預存程序?

來源:互聯網
上載者:User
不知道能不能用,我看provider只有2種,一種為sqlSchemaprovider,還有一個為adoxschemaprovider,模板寫好後,編譯就提示錯誤,


在對應所需名稱或序數的集合中,未找到項目。

An error of type "COMException"
occured while attempting to execute this template.  To enable
Just-In-Time debugging on this template set the "Debug" attribute to
"True" in the "CodeTemplate" directive and add a "Debugger.Break()"
statement in the template.

下面為我的模板
<%@ CodeTemplate Language="C#" TargetLanguage="T-SQL"
      Description="Generates a update stored procedure." %>
 
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema"
      Category="Context"
      Description="Table that the stored procedures should be based on." %>
 
<%@ Assembly Name="SchemaExplorer" %>
 
<%@ Import Namespace="SchemaExplorer" %>
     
<script runat="template">
public string GetSqlParameterStatement(ColumnSchema column)
{
      string param = "@" + column.Name + " " + column.NativeType;
 
      switch (column.DataType)
      {
            case DbType.Decimal:
            {
                 
param += "(" + column.Precision + ", " + column.Scale + ")";
                  break;
            }
            default:
            {
                  if (column.Size > 0)
                  {
                       
param += "(" + column.Size + ")";
                  }
                  break;
            }
      }
 
      return param;
}
</script>
 
-----------------------------------------------------------------
-- Date Created: <%= DateTime.Now.ToLongDateString() %>
-- Created By:   Generated by CodeSmith
-----------------------------------------------------------------
 
CREATE PROCEDURE dbo.Update<%= SourceTable.Name %>
      <% for (int i = 0; i < SourceTable.Columns.Count; i++) { %>
      <%=
GetSqlParameterStatement(SourceTable.Columns[i]) %><% if (i <
SourceTable.Columns.Count - 1) { %>,<% } %>
      <% } %>
AS
 
UPDATE [<%= SourceTable.Name %>] SET
      <% for (int i = 0; i < SourceTable.NonPrimaryKeyColumns.Count; i++) { %>
      [<%=
SourceTable.NonPrimaryKeyColumns[i].Name %>] = @<%=
SourceTable.NonPrimaryKeyColumns[i].Name %><% if (i <
SourceTable.NonPrimaryKeyColumns.Count - 1) { %>,<% } %>
      <% } %>
WHERE
      <% for (int i = 0; i < SourceTable.PrimaryKey.MemberColumns.Count; i++) { %>
      <% if (i > 0) { %>AND <% } %>
      [<%=
SourceTable.PrimaryKey.MemberColumns[i].Name %>] = @<%=
SourceTable.PrimaryKey.MemberColumns[i].Name %>
      <% } %>
sql server已經通過了。oracle則提示上面的錯誤。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.