本文整理汇总了C#中SqlCeEngine.Verify方法的典型用法代码示例。如果您正苦于以下问题:C# SqlCeEngine.Verify方法的具体用法?C# SqlCeEngine.Verify怎么用?C# SqlCeEngine.Verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlCeEngine
的用法示例。
在下文中一共展示了SqlCeEngine.Verify方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: compactDatabase
// Calls SQLCE's compactor
public void compactDatabase()
{
string connString = @"Data Source = " + dbPath; // Create connection string for SQLCE DB
SqlCeEngine engine = new SqlCeEngine(connString); // Instantiate engine object
// Do the compaction
engine.Compact(null);
// We then verify the database, just incase.
if (!engine.Verify())
{
throw new Exception("Database corrupt");
}
}
示例2: EnsureDatabaseIntegrity
/// <summary>
/// Ensures the database integrity.
/// </summary>
/// <param name="systemId">The system id.</param>
/// <param name="descriptor">The descriptor.</param>
/// <param name="mode">The mode.</param>
/// <exception cref="UnexpectedNHibernateConfigurationException">
/// Unexpected dialect.
/// or
/// Unexpected connection driver.
/// </exception>
/// <exception cref="InvalidConfigurationException">
/// Unable to find connection information in NHibernate Descriptor settings.
/// or
/// Unable to find data source in connection string.
/// </exception>
/// <exception cref="DatabaseVerificationErrorException"></exception>
public virtual void EnsureDatabaseIntegrity(long systemId, Dictionary<string, string> descriptor, SchemaFactoryModeEnum mode)
{
if (descriptor == null)
{
ThrowHelper.ThrowArgumentNullException("descriptor");
}
if (descriptor.ContainsKey(DIALECT))
{
string dialect = descriptor[DIALECT];
if (!dialect.StartsWith(DIALECT_EXPECTED_VALUE_BUILTIN) && !dialect.StartsWith(DIALECT_EXPECTED_VALUE_CUSTOM))
{
throw new UnexpectedNHibernateConfigurationException("Unexpected dialect.");
}
}
if (descriptor.ContainsKey(CONNECTION_DRIVER))
{
if (!CONNECTION_DRIVER_EXPECTED_VALUE.Equals(descriptor[CONNECTION_DRIVER]))
{
throw new UnexpectedNHibernateConfigurationException("Unexpected connection driver.");
}
}
string databaseFile = string.Empty;
string connectionString = string.Empty;
if (descriptor.ContainsKey(CONNECTION_STRING))
{
connectionString = descriptor[CONNECTION_STRING];
databaseFile = GetDatabaseFile(connectionString);
}
else if (descriptor.ContainsKey(CONNECTION_STRING_NAME))
{
connectionString = ConfigurationManager.ConnectionStrings[descriptor[CONNECTION_STRING_NAME]].ConnectionString;
databaseFile = GetDatabaseFile(connectionString);
}
else
{
throw new InvalidConfigurationException("Unable to find connection information in NHibernate Descriptor settings.");
}
if (string.IsNullOrEmpty(databaseFile))
{
throw new InvalidConfigurationException("Unable to find data source in connection string.");
}
using (SqlCeEngine en = new SqlCeEngine(connectionString))
{
FileInfo dbFileInfo = new FileInfo(databaseFile);
if (!dbFileInfo.Exists)
{
en.CreateDatabase();
}
else
{
if (mode == SchemaFactoryModeEnum.Create || mode == SchemaFactoryModeEnum.Create_And_Drop)
{
dbFileInfo.Delete();
en.CreateDatabase();
}
else
{
if (!en.Verify(VerifyOption.Enhanced))
{
throw new DatabaseVerificationErrorException();
}
}
}
}
}
示例3: TryInstall
public override InstallStatus TryInstall()
{
switch (_localConfig.Driver)
{
case SupportedNHDrivers.MsSqlCe4:
using (new WriteLockDisposable(SchemaValidationLocker))
{
using (var sqlCeEngine = new SqlCeEngine(_configuration.Properties[Environment.ConnectionString]))
{
if (!sqlCeEngine.Verify())
{
sqlCeEngine.CreateDatabase();
}
}
}
break;
}
InstallStatus installStatus;
try
{
var schemaAlreadyValid = ValidateSchema(_configuration);
if (schemaAlreadyValid)
return new InstallStatus(InstallStatusType.Completed);
UpdateSchema(_configuration);
installStatus = new InstallStatus(InstallStatusType.Completed);
}
catch (Exception ex)
{
installStatus = new InstallStatus(InstallStatusType.TriedAndFailed, ex);
}
return installStatus;
}
示例4: Verify
/// <summary>
/// Recalculates the checksums for each page in the database and compares the new checksums to the expected values. Also verifies
/// that each index entry exists in the table and that each table entry exists in the index. Applies only to SQL CE.
/// </summary>
/// <returns>
/// <c>True</c> if there is no database corruption; otherwise, <c>false</c>.
/// </returns>
internal static bool Verify()
{
using (SqlCeEngine engine = new SqlCeEngine(Util.ConnectionString))
{
return engine.Verify(VerifyOption.Enhanced);
}
}
示例5: VerifyDatabase
public void VerifyDatabase(string connectionString)
{
using (SqlCeEngine engine = new SqlCeEngine(connectionString))
{
engine.Verify(VerifyOption.Enhanced);
}
}
示例6: verifyDatabase
// Calls SQLCE's verification function
public bool verifyDatabase()
{
string connString = @"Data Source = " + dbPath; // Create connection string for SQLCE DB
SqlCeEngine engine = new SqlCeEngine(connString); // Instantiate engine object
if (!engine.Verify())
{
throw new Exception("Database corrupt"); // Host application should use a try..catch block to catch this
}
return true; // Return true as Database is intact
}
示例7: Verify
/// <summary>
/// Recalculates the checksums for each page in the database and compares the new checksums to the expected values. Also verifies
/// that each index entry exists in the table and that each table entry exists in the index.
/// </summary>
/// <returns>
/// <c>True</c> if there is no database corruption; otherwise, <c>false</c>.
/// </returns>
public bool Verify()
{
using (var engine = new SqlCeEngine(ConnectionString))
{
return engine.Verify(VerifyOption.Enhanced);
}
// Same thing using Reflection:
//object sqlCeEngine = null;
//try
//{
// sqlCeEngine = SqlCeEngineType.InvokeMember(null, BindingFlags.CreateInstance, null, null, new object[] { ConnectionString });
// var verifyOptionEnumType = SqlCeAssembly.GetType("System.Data.SqlServerCe.VerifyOption");
// var verifyOptionEnhanced = verifyOptionEnumType.GetField("Enhanced").GetValue(verifyOptionEnumType);
// var rv = SqlCeEngineType.InvokeMember("Verify", BindingFlags.InvokeMethod, null, sqlCeEngine, new[] { verifyOptionEnhanced });
// return Convert.ToBoolean(rv);
//}
//catch (TargetInvocationException ex)
//{
// AppEventController.LogError(ex.InnerException ?? ex);
// throw;
//}
//finally
//{
// if (sqlCeEngine != null)
// SqlCeEngineType.InvokeMember("Dispose", BindingFlags.InvokeMethod, null, sqlCeEngine, null);
//}
}