public static CartCollection Where(WhereDelegate <CartColumns> where, OrderBy <CartColumns> orderBy = null, Database database = null) { database = database ?? Db.For <Cart>(); var results = new CartCollection(database, database.GetQuery <CartColumns, Cart>(where, orderBy), true); return(results); }
/// <summary> /// Return every record in the Cart table. /// </summary> /// <param name="database"> /// The database to load from or null /// </param> public static CartCollection LoadAll(Database database = null) { SqlStringBuilder sql = new SqlStringBuilder(); sql.Select <Cart>(); Database db = database ?? Db.For <Cart>(); var results = new CartCollection(sql.GetDataTable(db)); results.Database = db; return(results); }
private static Cart OneOrThrow(CartCollection c) { if (c.Count == 1) { return(c[0]); } else if (c.Count > 1) { throw new MultipleEntriesFoundException(); } return(null); }
/// <summary> /// Execute a query and return the first result /// </summary> /// <param name="where">A WhereDelegate that recieves a CartColumns /// and returns a IQueryFilter which is the result of any comparisons /// between CartColumns and other values /// </param> /// <param name="db"></param> public static Cart FirstOneWhere(WhereDelegate <CartColumns> where, Database db = null) { var results = new CartCollection(db, Select <CartColumns> .From <Cart>().Where(where, db)); if (results.Count > 0) { return(results[0]); } else { return(null); } }
/// <summary> /// This method is intended to respond to client side Qi queries. /// Use of this method from .Net should be avoided in favor of /// one of the methods that take a delegate of type /// WhereDelegate<CartColumns>. /// </summary> /// <param name="where"></param> /// <param name="database"></param> public static CartCollection Where(QiQuery where, Database database = null) { var results = new CartCollection(database, Select <CartColumns> .From <Cart>().Where(where, database)); return(results); }
/// <summary> /// This method is intended to respond to client side Qi queries. /// Use of this method from .Net should be avoided in favor of /// one of the methods that take a delegate of type /// WhereDelegate<CartColumns>. /// </summary> /// <param name="where"></param> /// <param name="db"></param> public static Cart OneWhere(QiQuery where, Database db = null) { var results = new CartCollection(db, Select <CartColumns> .From <Cart>().Where(where, db)); return(OneOrThrow(results)); }
/// <summary> /// Execute a query and return the results. /// </summary> /// <param name="where">A WhereDelegate that recieves a CartColumns /// and returns a IQueryFilter which is the result of any comparisons /// between CartColumns and other values /// </param> /// <param name="orderBy"> /// Specifies what column and direction to order the results by /// </param> /// <param name="db"></param> public static CartCollection Where(WhereDelegate <CartColumns> where, OrderBy <CartColumns> orderBy = null, Database db = null) { var results = new CartCollection(db, new Query <CartColumns, Cart>(where, orderBy, db), true); return(results); }