/// <summary> /// Converts any Database instance into a queryable database. /// </summary> /// <param name="db"></param> /// <returns>Queryable database instance that operates on the same /// MSI handle.</returns> /// <remarks> /// This extension method is meant for convenient on-the-fly conversion. /// If the existing database instance already happens to be a QDatabase, /// then it is returned unchanged. Otherwise since the new database /// carries the same MSI handle, only one of the instances needs to be /// closed, not both. /// </remarks> public static QDatabase AsQueryable(this Database db) { QDatabase qdb = db as QDatabase; if (qdb == null && db != null) { qdb = new QDatabase(db.Handle, true, db.FilePath, db.OpenMode); } return(qdb); }
internal Query(QDatabase db, Expression expression) { if (expression == null) { throw new ArgumentNullException("expression"); } this.db = db; this.queryableExpression = expression; this.tables = new List <TableInfo>(); this.recordTypes = new List <Type>(); this.selectors = new List <string>(); this.whereParameters = new List <object>(); this.orderbyColumns = new List <TableColumn>(); this.selectColumns = new List <TableColumn>(); this.joinColumns = new List <TableColumn>(); this.projectionDelegates = new List <Delegate>(); }
/// <summary> /// Creates a new QTable with an explicit table name. /// </summary> /// <param name="db">database that contains the table</param> /// <param name="table">name of the table</param> public QTable(QDatabase db, string table) { if (db == null) { throw new ArgumentNullException("db"); } if (string.IsNullOrWhiteSpace(table)) { throw new ArgumentNullException("table"); } this.db = db; this.tableInfo = db.Tables[table]; if (this.tableInfo == null) { throw new ArgumentException( "Table does not exist in database: " + table); } }
/// <summary> /// Creates a new QTable, inferring the table name /// from the name of the record type parameter. /// </summary> /// <param name="db">database that contains the table</param> public QTable(QDatabase db) : this(db, InferTableName()) { }