예제 #1
0
파일: Cart.cs 프로젝트: ThreeHeadz/Bam.Net
        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);
        }
예제 #2
0
파일: Cart.cs 프로젝트: ThreeHeadz/Bam.Net
        /// <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);
        }
예제 #3
0
파일: Cart.cs 프로젝트: ThreeHeadz/Bam.Net
        private static Cart OneOrThrow(CartCollection c)
        {
            if (c.Count == 1)
            {
                return(c[0]);
            }
            else if (c.Count > 1)
            {
                throw new MultipleEntriesFoundException();
            }

            return(null);
        }
예제 #4
0
        /// <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);
            }
        }
예제 #5
0
파일: Cart.cs 프로젝트: ThreeHeadz/Bam.Net
        /// <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&lt;CartColumns&gt;.
        /// </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);
        }
예제 #6
0
        /// <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));
        }
예제 #7
0
        /// <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);
        }