コード例 #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;
        }