Example #1
0
        static public Task <DbDataReader> ExecuteReader(IQuery query, bool onQueue = true)
        {
            var work = new WorkPackage <DbDataReader>(WorkType.Read, query);

            if (/*Config.DefaultCacheLevel == CacheLevel.Off ||*/ !onQueue)
            {
                return(work.DoWorkAsync());
            }
            else
            {
                GetWorker(query.DatabaseProvider).Enqueue(work);
                return(work.AwaitResult());
            }
        }
Example #2
0
        public static Task <T> ExecuteScalar <T>(Database database, bool onQueue, params IQuery[] queries)
        {
            var work = new WorkPackage <T>(WorkType.Scalar, queries);

            if (/*Config.DefaultCacheLevel == CacheLevel.Off ||*/ !onQueue)
            {
                return(work.DoWorkAsync());
            }
            else
            {
                GetWorker(database).Enqueue(work);
                return(work.AwaitResult());
            }

            //return Task<T>.Factory.StartNew(() => DbAccess.ExecuteScalar<T>(queries));
        }
Example #3
0
        public static Task <bool> ExecuteNonQuery(Database database, params IQuery[] queries)
        {
            //if (Config.DefaultCacheLevel == CacheLevel.Off)
            //    DbAccess.ExecuteNonQuery(queries);
            //else
            //{
            //foreach (var list in queries.GroupBy(x => x.DatabaseProvider))
            //{
            //new WorkPackage<object>(WorkType.Write, list.ToArray()).DoWorkAsync();
            var work = new WorkPackage <bool>(WorkType.Write, queries);

            GetWorker(database).Enqueue(work);

            return(work.AwaitResult());
            //}
            //}
        }