예제 #1
0
파일: Query.cs 프로젝트: ppetrov/Cchbc
        public Query(string statement, QueryParameter[] parameters = null)
        {
            if (statement == null) throw new ArgumentNullException(nameof(statement));

            this.Statement = statement;
            this.Parameters = parameters ?? Enumerable.Empty<QueryParameter>().ToArray();
        }
예제 #2
0
        private static Task<List<DashboardFeatureByCount>> GetUsedFeaturesAsync(DashboarLoadParams loadParams, string query, QueryParameter[] sqlParams)
        {
            var dbContext = loadParams.FeatureContext.DbContext;
            var features = loadParams.Data.Features;
            var contexts = loadParams.Data.Contexts;

            var mostUsedFeatures = dbContext.Execute(new Query<DashboardFeatureByCount>(query, r =>
            {
                var featureId = r.GetInt64(0);
                var feature = features[featureId];
                var context = contexts[feature.ContextId];
                return new DashboardFeatureByCount(context, feature, r.GetInt32(1));
            }, sqlParams));

            return Task.FromResult(mostUsedFeatures);
        }
예제 #3
0
        private static QueryParameter[] CreateBatchParams(int batchSize)
        {
            var sqlParams = new QueryParameter[batchSize];

            for (var i = 0; i < sqlParams.Length; i++)
            {
                sqlParams[i] = new QueryParameter(@"p" + i);
            }

            return sqlParams;
        }