Ejemplo n.º 1
0
        public FeatureUser(UserRow row)
        {
            if (row == null) throw new ArgumentNullException(nameof(row));

            this.Row = row;
            this.Name = row.Name;
        }
Ejemplo n.º 2
0
        private static Dictionary<long, UserRow> GetUsers(IDbContext context, List<ExceptionEntryRow> entries)
        {
            var values = new Dictionary<long, UserRow>(entries.Count);

            var batchSize = 16;
            var sqlParams = CreateBatchParams(batchSize);

            var query = new Query(@"SELECT ID, NAME FROM FEATURE_USERS 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.UserId).Distinct())
            {
                if (index < batchSize)
                {
                    sqlParams[index++].Value = id;
                    continue;
                }

                context.Fill(values, (r, map) =>
                {
                    var row = new UserRow(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 UserRow(r.GetInt64(0), r.GetString(1));
                    map.Add(row.Id, row);
                }, query);
            }

            return values;
        }