示例#1
0
        public async Task <bool> loadAsync <T>(T registry) where T : class, new()
        {
            ConfigStatement c;
            bool            result;

            await this.Semaphore.WaitAsync();

            try
            {
                c = this.getConfigSelect(registry);

                this.addParameters(c.Params);

                using (SQLData d = await this.executeAsync(c.SQL))
                {
                    if (d.next())
                    {
                        d.fill <T>(registry);
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
            finally
            {
                this.Semaphore.Release();
            }

            return(result);
        }
示例#2
0
        public async Task <T> firstAsync <T>(string sql = "", string orderby = "", List <StatementParameter> parameters = null) where T : class, new()
        {
            ConfigStatement c;
            T result;

            if (sql == null)
            {
                sql = "";
            }

            await this.Semaphore.WaitAsync();

            try
            {
                c = this.getConfigSelect(new T(), true);

                if (parameters != null)
                {
                    this.addParameters(parameters);
                }

                using (SQLData d = await this.executeAsync(c.SELECT + " " + sql + " LIMIT 1"))
                {
                    if (d.next())
                    {
                        result = d.fill <T>();
                    }
                    else
                    {
                        result = null;
                    }
                }
            }
            finally
            {
                this.Semaphore.Release();
            }

            return(result);
        }