private static Dictionary<string, long> GetDataMapped(IDbContext context, string statement) { var result = new Dictionary<string, long>(32); context.Fill(result, (r, map) => { map.Add(r.GetString(1), r.GetInt64(0)); }, new Query(statement)); return result; }
private static Dictionary<long, VersionRow> GetVersions(IDbContext context, List<ExceptionEntryRow> entries) { var values = new Dictionary<long, VersionRow>(entries.Count); var batchSize = 16; var sqlParams = CreateBatchParams(batchSize); var query = new Query(@"SELECT ID, NAME FROM FEATURE_VERSIONS WHERE ID IN (@p0,@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9,@p10,@p11,@p12,@p13,@p14,@p15)", sqlParams); var index = 0; foreach (var id in entries.Select(r => r.VersionId).Distinct()) { if (index < batchSize) { sqlParams[index++].Value = id; continue; } context.Fill(values, (r, map) => { var row = new VersionRow(r.GetInt64(0), r.GetString(1)); map.Add(row.Id, row); }, query); sqlParams[0].Value = id; index = 1; } if (index > 0) { for (var i = index; i < sqlParams.Length; i++) { sqlParams[i].Value = -1; } context.Fill(values, (r, map) => { var row = new VersionRow(r.GetInt64(0), r.GetString(1)); map.Add(row.Id, row); }, query); } return values; }
private static Dictionary<long, int> CountByVersion(IDbContext context, string query) { var result = new Dictionary<long, int>(); context.Fill(result, (r, map) => { var versionId = r.GetInt64(0); var count = r.GetInt32(1); map[versionId] = count; }, new Query(query)); return result; }
public static Dictionary<string, DbFeatureContextRow> GetContexts(IDbContext context) { if (context == null) throw new ArgumentNullException(nameof(context)); var result = new Dictionary<string, DbFeatureContextRow>(); context.Fill(result, (r, map) => { var row = DbContextCreator(r); map.Add(row.Name, row); }, new Query(GetContextsQuery.Statement)); return result; }