EFOracleProvider的最后发布时间是2008年,但是居然不支持Oracle9i。
用Oracle官方的组件吧,两个问题:
1. 组件好大啊,好几百兆
2. 最重要在于,一直在beta
但是经理说要将俺们的技术升级到2010,用Entity Framework+MVC+JQuery
那就上吧。
第一个问题,就是支持9i的问题——声明一下,这个解决办法是在网上搜来的。写在这里只是为了汇总。
为了让EFOracleProvider支持9i,需要修改3个类:EFOracleVersion、EFOracleProviderManifest、EFOracleVersionUtils(在EFOracleVersion.cs中)
1. 在enum EFOracleVersion中添加一个enum值,如下
/// <summary>
/// Oracle9i
/// </summary>
Oracle9i = 9,
/// </summary>
Oracle9i = 9,
2. 在EFOracleProviderManifest中添加一个const值
internal const string TokenOracle9i = "9i";
3. 修改EFOracleVersionUtils类,如下,
View Code
/// <summary>
/// This class is a simple utility class that determines the version from the
/// connection
/// </summary>
internal static class EFOracleVersionUtils
{
/// <summary>
/// Get the version from the connection.
/// </summary>
/// <param name="connection">current connection</param>
/// <returns>version for the current connection</returns>
internal static EFOracleVersion GetStorageVersion(EFOracleConnection connection)
{
string serverVersion = connection.ServerVersion;
if (serverVersion.StartsWith("9."))
{
return EFOracleVersion.Oracle9i;
}
else if (serverVersion.StartsWith("10."))
{
return EFOracleVersion.Oracle10g;
}
else if (serverVersion.StartsWith("11."))
{
return EFOracleVersion.Oracle11g;
}
throw new ArgumentException("Could not determine storage version; " +
"a valid storage connection or a version hint is required.");
}
internal static string GetVersionHint(EFOracleVersion version)
{
switch (version)
{
case EFOracleVersion.Oracle9i:
return EFOracleProviderManifest.TokenOracle9i;
case EFOracleVersion.Oracle10g:
return EFOracleProviderManifest.TokenOracle10g;
case EFOracleVersion.Oracle11g:
return EFOracleProviderManifest.TokenOracle11g;
default:
throw new ArgumentException("Could not determine storage version; " +
"a valid storage connection or a version hint is required.");
}
}
internal static EFOracleVersion GetStorageVersion(string versionHint)
{
if (!string.IsNullOrEmpty(versionHint))
{
switch (versionHint)
{
case EFOracleProviderManifest.TokenOracle9i:
return EFOracleVersion.Oracle9i;
case EFOracleProviderManifest.TokenOracle10g:
return EFOracleVersion.Oracle10g;
case EFOracleProviderManifest.TokenOracle11g:
return EFOracleVersion.Oracle11g;
}
}
throw new ArgumentException("Could not determine storage version; " +
"a valid storage connection or a version hint is required.");
}
internal static bool IsVersionX(EFOracleVersion storageVersion)
{
return storageVersion == EFOracleVersion.Oracle9i || storageVersion == EFOracleVersion.Oracle10g ||
storageVersion == EFOracleVersion.Oracle11g;
}
/// This class is a simple utility class that determines the version from the
/// connection
/// </summary>
internal static class EFOracleVersionUtils
{
/// <summary>
/// Get the version from the connection.
/// </summary>
/// <param name="connection">current connection</param>
/// <returns>version for the current connection</returns>
internal static EFOracleVersion GetStorageVersion(EFOracleConnection connection)
{
string serverVersion = connection.ServerVersion;
if (serverVersion.StartsWith("9."))
{
return EFOracleVersion.Oracle9i;
}
else if (serverVersion.StartsWith("10."))
{
return EFOracleVersion.Oracle10g;
}
else if (serverVersion.StartsWith("11."))
{
return EFOracleVersion.Oracle11g;
}
throw new ArgumentException("Could not determine storage version; " +
"a valid storage connection or a version hint is required.");
}
internal static string GetVersionHint(EFOracleVersion version)
{
switch (version)
{
case EFOracleVersion.Oracle9i:
return EFOracleProviderManifest.TokenOracle9i;
case EFOracleVersion.Oracle10g:
return EFOracleProviderManifest.TokenOracle10g;
case EFOracleVersion.Oracle11g:
return EFOracleProviderManifest.TokenOracle11g;
default:
throw new ArgumentException("Could not determine storage version; " +
"a valid storage connection or a version hint is required.");
}
}
internal static EFOracleVersion GetStorageVersion(string versionHint)
{
if (!string.IsNullOrEmpty(versionHint))
{
switch (versionHint)
{
case EFOracleProviderManifest.TokenOracle9i:
return EFOracleVersion.Oracle9i;
case EFOracleProviderManifest.TokenOracle10g:
return EFOracleVersion.Oracle10g;
case EFOracleProviderManifest.TokenOracle11g:
return EFOracleVersion.Oracle11g;
}
}
throw new ArgumentException("Could not determine storage version; " +
"a valid storage connection or a version hint is required.");
}
internal static bool IsVersionX(EFOracleVersion storageVersion)
{
return storageVersion == EFOracleVersion.Oracle9i || storageVersion == EFOracleVersion.Oracle10g ||
storageVersion == EFOracleVersion.Oracle11g;
}
这样,EFOracleProvider就能支持Oracle9i了。
修改EFOracleProvider系列预告
修改EFOracleProvider——让EFOracleProvider支持自增长类型
修改EFOracleProvider——让EFOracleProvider支持int, short, byte, bit
修改过的EFOracleProvider下载