Пример #1
0
        public DBStorage(DbProviderFactory factory, string connectionString, string tableName)
        {
            factory.ThrowIfNull("factory");
            connectionString.ThrowIfNull("connectionString");
            tableName.ThrowIfNull("tableName");
            this._Factory = factory;
            this._ConnectionString = connectionString;

            this.Transaction((conn, tx) => {
                using(var com = conn.CreateCommand()) {
                    com.CommandText = String.Format(CREATE_TABLE, tableName);
                    com.ExecuteNonQuery();
                }
            });

            this._Insert = String.Format(INSERT, tableName);
            this._InsertOrReplace = String.Format(INSERT_OR_REPLACE, tableName);
            this._Select = String.Format(SELECT, tableName);
            this._SelectCount = String.Format(SELECT_COUNT, tableName);
            this._SelectAll = String.Format(SELECT_ALL, tableName);
            this._SelectAllValues = String.Format(SELECT_ALL_VALUES, tableName);
            this._SelectAllKeys = String.Format(SELECT_ALL_KEYS, tableName);
            this._SelectAllLimit = String.Format(SELECT_ALL_LIMIT, tableName);
            this._Delete = String.Format(DELETE, tableName);
            this._DeleteAll = String.Format(DELETE_ALL, tableName);
        }