Пример #1
0
        /// <summary>
        /// Execute a query and return the results.
        /// </summary>
        /// <param name="where">A WhereDelegate that recieves a ParentColumns
        /// and returns a IQueryFilter which is the result of any comparisons
        /// between ParentColumns and other values
        /// </param>
        /// <param name="orderBy">
        /// Specifies what column and direction to order the results by
        /// </param>
        /// <param name="database"></param>
        public static ParentCollection Where(WhereDelegate <ParentColumns> where, OrderBy <ParentColumns> orderBy = null, Database database = null)
        {
            database = database ?? Db.For <Parent>();
            var results = new ParentCollection(database, database.GetQuery <ParentColumns, Parent>(where, orderBy), true);

            return(results);
        }
Пример #2
0
        /// <summary>
        /// Return every record in the Parent table.
        /// </summary>
        /// <param name="database">
        /// The database to load from or null
        /// </param>
        public static ParentCollection LoadAll(Database database = null)
        {
            SqlStringBuilder sql = new SqlStringBuilder();

            sql.Select <Parent>();
            Database db      = database ?? Db.For <Parent>();
            var      results = new ParentCollection(sql.GetDataTable(db));

            results.Database = db;
            return(results);
        }
Пример #3
0
        private static Parent OneOrThrow(ParentCollection c)
        {
            if (c.Count == 1)
            {
                return(c[0]);
            }
            else if (c.Count > 1)
            {
                throw new MultipleEntriesFoundException();
            }

            return(null);
        }
Пример #4
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&lt;ParentColumns&gt;.
        /// </summary>
        /// <param name="where"></param>
        /// <param name="database"></param>
        public static ParentCollection Where(QiQuery where, Database database = null)
        {
            var results = new ParentCollection(database, Select <ParentColumns> .From <Parent>().Where(where, database));

            return(results);
        }