static StoredScript()
{
if (DatabaseFactory.DefaultProviderName == DatabaseFactory.OleDbProvider)
PopulateScriptFromProvider(typeof(OleDbScriptProvider));
else if (DatabaseFactory.DefaultProviderName == DatabaseFactory.OracleClientProvider)
PopulateScriptFromProvider(typeof(OracleScriptProvider));
else if (DatabaseFactory.DefaultProviderName == DatabaseFactory.SqlClientProvider)
PopulateScriptFromProvider(typeof(SqlScriptProvider));
else
throw new NotSupportedException(DatabaseFactory.DefaultProviderName);
}
/// <summary>
/// 初使化SQL字典
/// </summary>
/// <param name="type"></param>
private static void PopulateScriptFromProvider(Type type)
{
PropertyInfo[] propertys= type.GetProperties();
object instance = Activator.CreateInstance(type);
foreach (PropertyInfo prop in propertys)
{
object propValue = prop.GetValue(instance, null);
if (propValue != null)
_keySql.Add(prop.Name, propValue.ToString());
}
}
{
if (DatabaseFactory.DefaultProviderName == DatabaseFactory.OleDbProvider)
PopulateScriptFromProvider(typeof(OleDbScriptProvider));
else if (DatabaseFactory.DefaultProviderName == DatabaseFactory.OracleClientProvider)
PopulateScriptFromProvider(typeof(OracleScriptProvider));
else if (DatabaseFactory.DefaultProviderName == DatabaseFactory.SqlClientProvider)
PopulateScriptFromProvider(typeof(SqlScriptProvider));
else
throw new NotSupportedException(DatabaseFactory.DefaultProviderName);
}
/// <summary>
/// 初使化SQL字典
/// </summary>
/// <param name="type"></param>
private static void PopulateScriptFromProvider(Type type)
{
PropertyInfo[] propertys= type.GetProperties();
object instance = Activator.CreateInstance(type);
foreach (PropertyInfo prop in propertys)
{
object propValue = prop.GetValue(instance, null);
if (propValue != null)
_keySql.Add(prop.Name, propValue.ToString());
}
}