/// <summary> /// Loads database schema for <paramref name="connection"/>. /// </summary> /// <param name="connection">Database connection.</param> /// <returns>Database schema.</returns> /// <remarks> /// Loading schema creates a new connection to database based on <paramref name="connection"/>. If loading with /// new connection fails (for example input connection is exclusive), schema is loaded using input /// <paramref name="connection"/> directly.</remarks> /// <exception cref="ArgumentNullException">Value of <paramref name="connection"/> id <see langword="null"/>.</exception> /// <exception cref="ArgumentException">The connection <paramref name="connection"/> is not a connection /// to Microsoft Access database.</exception> public DatabaseSchema LoadSchema(OleDbConnection connection) { CheckConnection(connection); if (MsAccessDataHelper.IsExclusiveMsAccessConnection(connection.ConnectionString)) { return(LoadSchemaCore(connection)); } using (OleDbConnection cn = (OleDbConnection)(connection as ICloneable).Clone()) { cn.Open(); return(LoadSchemaCore(cn)); } }
/// <summary> /// Loads table schema for table <paramref name="tableName"/> in database <paramref name="connection"/>. /// </summary> /// <param name="connection">Database connection.</param> /// <param name="tableName">Table name.</param> /// <returns>Table schema, or value <see langword="null"/> if specified table does not exist.</returns> /// <remarks> /// Loading schema creates a new connection to database based on <paramref name="connection"/>. If loading with /// new connection fails (for example input connection is exclusive), schema is loaded using input /// <paramref name="connection"/> directly.</remarks> /// <exception cref="ArgumentNullException"> /// <list type="bullet"> /// <item>Value of <paramref name="connection"/> is <see langword="null"/>.</item> /// <item>Value of <paramref name="tableName"/> is <see langword="null"/>.</item> /// </list> /// </exception> /// <exception cref="ArgumentException"> /// Value of <paramref name="tableName"/> is an empty string, or string containing whitespace characters only. /// </exception> public TableSchema LoadTableSchema(OleDbConnection connection, string tableName) { CheckConnection(connection); Check.NotNullOrWhiteSpace(tableName, nameof(tableName)); if (MsAccessDataHelper.IsExclusiveMsAccessConnection(connection.ConnectionString)) { return(LoadTableSchemaCore(connection, tableName)); } using (OleDbConnection cn = (OleDbConnection)(connection as ICloneable).Clone()) { cn.Open(); return(LoadTableSchemaCore(cn, tableName)); } }