我正在编写使用 postgres 数据库的代码。这段代码已经使用了 oracle 特定的函数,我添加了一些函数来访问 postgres 表。需要进行仅使用 postgres 功能的构建,不需要 oracle 代码行,因此不需要 ODAC。
http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html
有一些选项,例如为 c# 添加条件编译,以便不为 postgres 执行 oracle 特定代码。这样做不会在编译的 dll 中添加基于 ODAC 的代码部分,因此不需要 ODAC,但这是唯一的方法。正如我所说,应用程序中有很多项目,进行条件编译会创建很多额外的代码。
或者还有什么可以避免 ODAC 许可的其他替代方案。
谢谢,
function GetData()
{
if(Postgres flag){
// code for using OracleClientFactory and initlizing the oraclecommand
}
else if(Oracle flag)
{
// code for using postgres and initlizing the its command object
}
}
// code to assign query to command object and execute the query
// return the resluts
catch (){}
finally{//dispoing the objects}
}
}