用codesmith能否生成访问oracle的存储过程?
不知道能不能用,我看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则提示上面的错误。
在对应所需名称或序数的集合中,未找到项目。
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则提示上面的错误。