CodeSmith的OracleProviders

网上发现一个CodeSmith的OracleProviders,希望对大家有帮助

献上Oracle导出数据的模板:

None.gif <% @ CodeTemplate Language = " C# "  TargetLanguage = " PL-SQL "  Description = " ??Oracle???????? "   %>
None.gif
<% @ Assembly Name = " SchemaExplorer "   %>
None.gif
<% @ Import Namespace = " SchemaExplorer "   %>
None.gif
<% @ Property Name = " SourceTable "  Type = " SchemaExplorer.TableSchema "  Category = " Context "  Description = ""   %>
None.gifCreated 
<%= DateTime.Now  %>
ExpandedBlockStart.gifContractedBlock.gif
<% for ( int  intRow = 0 ;intRow < SourceTableData.Rows.Count;intRow ++ ) dot.gif %>
InBlock.gifinsert into 
<%=GetTableOwner() %><%=SourceTable.Name %>(<%=AllColumns %>)
InBlock.gifvalues (
<%=AllDate(intRow) %>);
ExpandedBlockEnd.gif
<%}
%>
None.gif
< script runat = " template " >
None.gif
private  DataTable _sourceTableData;
None.gif
private   string  _allColumns;
None.gif
private   string  _allData;
None.gif
ContractedBlock.gifExpandedBlockStart.gif
SourceTableData #region SourceTableData
InBlock.gif
private DataTable SourceTableData
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
get
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
if (_sourceTableData == null)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            _sourceTableData 
= SourceTable.GetTableData();
ExpandedSubBlockEnd.gif        }

InBlock.gif        
InBlock.gif        
return _sourceTableData;
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif}

ExpandedBlockEnd.gif
#endregion

None.gif
ContractedBlock.gifExpandedBlockStart.gif
AllColumns #region AllColumns
InBlock.gif
private string AllColumns
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
get
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
if(_allColumns ==null)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
string strCols = "";
InBlock.gif            
for(int i=0;i<SourceTable.Columns.Count-1;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                strCols 
+= SourceTable.Columns[i].Name + ",";
ExpandedSubBlockEnd.gif            }

InBlock.gif            strCols
+=SourceTable.Columns[SourceTable.Columns.Count-1].Name;
InBlock.gif            _allColumns 
= strCols;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
return _allColumns;
InBlock.gif        
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif}

ExpandedBlockEnd.gif
#endregion

None.gif
ContractedBlock.gifExpandedBlockStart.gif
AllData #region AllData
InBlock.gif
private string AllDate(int intRow)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
string strVal = "";
InBlock.gif    
int intCol=0;
InBlock.gif    
for(;intCol<SourceTable.Columns.Count-1;intCol++)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        strVal 
+= Formated(SourceTableData.Rows[intRow][intCol],intCol,intRow) + ",";
ExpandedSubBlockEnd.gif    }

InBlock.gif    strVal 
+= Formated(SourceTableData.Rows[intRow][intCol],intCol,intRow);
InBlock.gif    
return  strVal;
ExpandedSubBlockEnd.gif}

ExpandedBlockEnd.gif
#endregion

None.gif
ContractedBlock.gifExpandedBlockStart.gif
FormatData #region FormatData
InBlock.gif
private string Formated(object obj,int intCol,int intRow)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
string strVal = "";
InBlock.gif    
switch(SourceTable.Columns[intCol].DataType)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
case DbType.String:
InBlock.gif            strVal 
= "'" + obj + "'";
InBlock.gif            
break;
InBlock.gif        
case DbType.Int16:
InBlock.gif        
case DbType.Int32:
InBlock.gif        
case DbType.Int64:
InBlock.gif            strVal 
= obj.ToString();
InBlock.gif            
break;
InBlock.gif        
case DbType.DateTime:
InBlock.gif            strVal 
= "to_date('" + obj + "','yyyy-mm-dd HH24:MI:SS')";
InBlock.gif            
break;
InBlock.gif        
default:
InBlock.gif            strVal 
="'"+ obj.ToString() + "'";
InBlock.gif            
break;
ExpandedSubBlockEnd.gif    }

InBlock.gif    
if (SourceTableData.Rows[intRow][intCol]==DBNull.Value)
InBlock.gif        strVal 
= "null";
InBlock.gif    
return strVal;
ExpandedSubBlockEnd.gif}

ExpandedBlockEnd.gif
#endregion

None.gif
None.gif
public   string  GetTableOwner()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
return GetTableOwner(true);
ExpandedBlockEnd.gif}

None.gif
None.gif
public   string  GetTableOwner( bool  includeDot)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
if (SourceTable.Owner.Length > 0)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
return  SourceTable.Owner + ".";
ExpandedSubBlockEnd.gif    }

InBlock.gif    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
return "";
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif
None.gif
</ script >
None.gif

Copy Provider DLL 文件到 CodeSmith的安装路径(D:\Program Files\CodeSmith\v4.0\SchemaProviders)
就可以用CodeSmith连接Oracle 数据库。
文件下载

转载于:https://www.cnblogs.com/mmmhhhlll/archive/2007/07/19/824635.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值