Exemple #1
0
        private static Counter OneOrThrow(CounterCollection c)
        {
            if (c.Count == 1)
            {
                return(c[0]);
            }
            else if (c.Count > 1)
            {
                throw new MultipleEntriesFoundException();
            }

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

            sql.Select <Counter>();
            Database db      = database ?? Db.For <Counter>();
            var      results = new CounterCollection(db, sql.GetDataTable(db))
            {
                Database = db
            };

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

            return(results);
        }