本文整理汇总了C#中DatabaseType类的典型用法代码示例。如果您正苦于以下问题:C# DatabaseType类的具体用法?C# DatabaseType怎么用?C# DatabaseType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseType类属于命名空间,在下文中一共展示了DatabaseType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckIfAuditTableExists
private static void CheckIfAuditTableExists(Type auditRecordType, DatabaseType databaseType)
{
var classConfig = ClassConfigContainer.FindClassConfig(auditRecordType);
var table = classConfig.TableName;
var sql = string.Empty;
if (databaseType != DatabaseType.Oracle)
{
sql = string.Format("SELECT COUNT(*) " +
"FROM INFORMATION_SCHEMA.TABLES " +
"WHERE TABLE_SCHEMA = '[Schema]' AND TABLE_NAME = '{0}' OR TABLE_NAME = '{1}' ",
table.ToLower(), table);
}
else
{
sql = string.Format("SELECT COUNT(*) FROM ALL_TABLES WHERE OWNER ='[Schema]' AND TABLE_NAME ='{0}'",
table);
}
var database = DatabaseCreator.CreateDatabase();
var result = database.ExecuteScalar(sql);
if (result.ToString() == "0")
{
throw new EasylinkException("Audit table {0} does not exist in the database.", table);
}
}
示例2: AddCeDatabase
private void AddCeDatabase(DatabaseType dbType)
{
try
{
var dialog = new ConnectionDialog();
string path;
if (TryGetInitialPath(package, out path))
{
dialog.InitialPath = path;
}
dialog.DbType = dbType;
dialog.ShowDDEXInfo = package.VSSupportsSimpleDDEX4Provider() || package.VSSupportsSimpleDDEX35Provider();
dialog.CouldSupportPrivateProvider =
(dbType == DatabaseType.SQLCE40 && (SqlCeToolboxPackage.VisualStudioVersion == new Version(12, 0) || SqlCeToolboxPackage.VisualStudioVersion == new Version(14, 0)) )
|| (dbType == DatabaseType.SQLCE35 && package.VSSupportsEF6());
bool? result = dialog.ShowModal();
if (result.HasValue && result.Value == true)
{
if (!string.IsNullOrWhiteSpace(dialog.ConnectionString))
{
Helpers.DataConnectionHelper.SaveDataConnection(dialog.ConnectionString, dbType, package);
ExplorerControl control = _parentWindow.Content as ExplorerControl;
control.BuildDatabaseTree();
Helpers.DataConnectionHelper.LogUsage("DatabasesAddCeDatabase");
}
}
}
catch (Exception ex)
{
Helpers.DataConnectionHelper.SendError(ex, dbType);
}
}
示例3: UpgradeDatabase
public static void UpgradeDatabase(DbConnection connection, DatabaseType databaseType)
{
// Figure out the current version of the schema
int currentVersion;
using (DbCommand cmd = connection.CreateCommand())
{
cmd.CommandText = "SELECT val FROM setup WHERE `key`='schemaVersion';";
using (DbDataReader reader = cmd.ExecuteReader())
{
if (!reader.Read())
currentVersion = 1;
else
currentVersion = int.Parse(reader.GetString(reader.GetOrdinal("val")));
}
}
// Now get the set of migrations we have avaiable
List<int> migrationVersions = GetMigrationVersions(databaseType);
foreach (int migration in migrationVersions)
{
if (currentVersion < migration)
{
PerformMigration(connection, databaseType, migration);
}
}
}
示例4: EntityAttribue
public EntityAttribue(string _TableName, string _ConectionName, DatabaseType _DbType, bool _EnableCache)
{
this.TableName = _TableName;
this.ConectionName = _ConectionName;
this.DbType = _DbType;
this.EnableCache = _EnableCache;
}
示例5: DirectionBinaryObject
public DirectionBinaryObject(XDirection direction, DatabaseType databaseType)
{
DatabaseType = databaseType;
ObjectType = ObjectType.Direction;
Direction = direction;
Build();
}
示例6: AddPutBit
public void AddPutBit(XStateType stateType, XBinaryBase binaryBase, DatabaseType databaseType)
{
Add(FormulaOperationType.PUTBIT,
(byte)stateType,
binaryBase.GetDatabaseNo(databaseType),
"Запись состояния " + stateType.ToDescription() + " " + XBinaryBaseToString(binaryBase));
}
示例7: ZoneBinaryObject
public ZoneBinaryObject(XZone zone, DatabaseType databaseType)
{
DatabaseType = databaseType;
ObjectType = ObjectType.Zone;
Zone = zone;
Build();
}
示例8: ConnectionInformation
public ConnectionInformation(string tableName, string connKey, string[] pirmaryKeys,DatabaseType dbType)
{
this.TableName = tableName;
this.ConnectionKey = connKey;
this.PrimaryKeys = pirmaryKeys;
this.DbType = dbType;
}
示例9: DataTableUNION
public static DataTable DataTableUNION(DatabaseType dbT, string cs, params string[] fieldTableUNION)
{
string req = "";
for (int i = 0; i < fieldTableUNION.Length - 2; i += 2)
{
req += "SELECT DISTINCT " + fieldTableUNION[i] + " FROM " + fieldTableUNION[i + 1] + " UNION ";
}
req += "SELECT DISTINCT " + fieldTableUNION[fieldTableUNION.Length - 2] + " FROM " + fieldTableUNION[fieldTableUNION.Length - 1];
DataTable t = new DataTable();
switch (dbT)
{
case DatabaseType.OleDb:
using (OleDbConnection c = Connection(dbT, cs) as OleDbConnection)
{
using (OleDbDataAdapter a = new OleDbDataAdapter(req, c))
{
a.Fill(t);
}
}
break;
default:
break;
}
return t;
}
示例10: DataTypeInstanceAttribute
public DataTypeInstanceAttribute(string propertyEditorAlias = null, string name = null, Type converterType = null, DatabaseType dbType = DatabaseType.None)
{
Name = name;
PropertyEditorAlias = propertyEditorAlias;
ConverterType = converterType;
DbType = dbType;
}
示例11: Create
public static DbTypeProvider Create(DatabaseType databaseType)
{
if (databaseType == DatabaseType.Postgres)
return new PostgresDbTypeProvider();
return null;
}
示例12: CreateCommand
public static IDbCommand CreateCommand(string CommandText, DatabaseType dbtype,
IDbConnection cnn)
{
IDbCommand cmd;
switch (dbtype)
{
case DatabaseType.Access:
cmd = new OleDbCommand
(CommandText,
(OleDbConnection)cnn);
break;
case DatabaseType.SQLServer:
cmd = new SqlCommand
(CommandText,
(SqlConnection)cnn);
break;
default:
cmd = new SqlCommand
(CommandText,
(SqlConnection)cnn);
break;
}
return cmd;
}
示例13: Create
/// <summary>
/// 获取数据库帮助对象。
/// </summary>
/// <param name="database">数据库类型</param>
/// <param name="host">数据库主机</param>
/// <param name="instance">数据库实例</param>
/// <param name="account">账号</param>
/// <param name="password">密码</param>
/// <param name="port">端口号</param>
/// <returns>数据库帮助对象</returns>
public static DbHelper Create(
DatabaseType database,
string host,
string instance,
string account,
string password,
int? port = null)
{
var connectionString = GetConnectionString(database, host, instance, account, password, port);
var dbHelper = new DbHelper(Providers[(int)database], connectionString);
switch (database)
{
case DatabaseType.MSSQL:
dbHelper.DbMetadata = new MSSQLMetadata();
break;
case DatabaseType.Oracle:
dbHelper.DbMetadata = new OracleMetadata();
break;
}
return dbHelper;
}
示例14: DatabaseQueryTransformRule
public DatabaseQueryTransformRule(string connectionString, DatabaseType dbType, string query, DicomTag[] outputTags, DicomTag[] paramTags) {
_connectionString = connectionString;
_dbType = dbType;
_query = query;
_output = new List<DicomTag>(outputTags);
_params = new List<DicomTag>(paramTags);
}
示例15: DataTable
public static DataTable DataTable(DatabaseType dbT, string cs, string req, params object[] paramaters)
{
DataTable t = new DataTable();
switch (dbT)
{
case DatabaseType.OleDb:
using (OleDbConnection c = Connection(dbT, cs) as OleDbConnection)
{
using (OleDbDataAdapter a = new OleDbDataAdapter(req, c))
{
for (int i = 0; i < paramaters.Length; i += 2)
{
if (req.Contains("@" + paramaters[i] as string))
{
a.SelectCommand.Parameters.AddWithValue("@" + paramaters[i] as string, paramaters[i + 1]);
}
}
a.Fill(t);
}
}
break;
default:
break;
}
return t;
}