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

            return(results);
        }
Example #2
0
        /// <summary>
        /// Return every record in the Son table.
        /// </summary>
        /// <param name="database">
        /// The database to load from or null
        /// </param>
        public static SonCollection LoadAll(Database database = null)
        {
            SqlStringBuilder sql = new SqlStringBuilder();

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

            results.Database = db;
            return(results);
        }
Example #3
0
        private static Son OneOrThrow(SonCollection c)
        {
            if (c.Count == 1)
            {
                return(c[0]);
            }
            else if (c.Count > 1)
            {
                throw new MultipleEntriesFoundException();
            }

            return(null);
        }
Example #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;SonColumns&gt;.
        /// </summary>
        /// <param name="where"></param>
        /// <param name="database"></param>
        public static SonCollection Where(QiQuery where, Database database = null)
        {
            var results = new SonCollection(database, Select <SonColumns> .From <Son>().Where(where, database));

            return(results);
        }