public async Task TruncateTableAsync()
 {
     using (var context = new DWHContext())
     {
         await context.Database.ExecuteSqlCommandAsync("TRUNCATE TABLE [Staging].[RAWMessage]");
     }
 }
 public async Task <List <State> > GetStatesAsync()
 {
     using (var context = new DWHContext())
     {
         return(await context.Set <State>()
                .ToListAsync());
     }
 }
 public static void Generate(DWHContext context)
 {
     if (!context.Set <Date>().Any())
     {
         PopulateData(context);
         PopulateConfiguration(context);
     }
 }
示例#4
0
 public async Task AddFactAsync <T>(T entity) where T : class
 {
     using (var context = new DWHContext())
     {
         context.Set <T>().Add(entity);
         await context.SaveChangesAsync();
     }
 }
 public async Task <State> GetStateByIdAsync(byte id)
 {
     using (var context = new DWHContext())
     {
         return(await context.Set <State>()
                .Where(i => i.Id == id)
                .SingleAsync());
     }
 }
 public async Task <List <RAWMessage> > GetAsync()
 {
     using (var context = new DWHContext())
     {
         return(await context.Set <RAWMessage>()
                .OrderBy(i => i.Id)
                .Take(1000)
                .ToListAsync());
     }
 }
        public async Task AddAsync(RAWMessage entity)
        {
            using (var context = new DWHContext())
            {
                context.Set <RAWMessage>()
                .Add(entity);

                await context.SaveChangesAsync();
            }
        }
示例#8
0
 public async Task <List <T> > GetAllAsync <T>()
     where T : class, IDimension
 {
     using (var context = new DWHContext())
     {
         return(await context
                .Set <T>()
                .ToListAsync());
     };
 }
        public async Task UpdateStateAsync(State state)
        {
            using (var context = new DWHContext())
            {
                var existingEntity = await context.Set <State>()
                                     .Where(i => i.Id == state.Id)
                                     .SingleAsync();

                context.Entry(existingEntity).CurrentValues.SetValues(state);

                await context.SaveChangesAsync();
            }
        }
示例#10
0
        public async Task <int> AddAsync <T>(T entity)
            where T : class, IDimension
        {
            int result = 0;

            using (var context = new DWHContext())
            {
                context.Set <T>().Add(entity);
                await context.SaveChangesAsync();

                result = entity.Id;

                return(result);
            }
        }
示例#11
0
        async Task <int> Save <T>(DWHContext context, T existingEntity, T entity)
            where T : class, IDimension
        {
            int result = 0;

            if (existingEntity == null)
            {
                context.Set <T>().Add(entity);
                await context.SaveChangesAsync();

                result = entity.Id;
            }
            else
            {
                result = existingEntity.Id;
            }

            return(result);
        }
示例#12
0
        public async Task UpsertAsync(List <Language> entities)
        {
            var distinctEntities = entities
                                   .Select(i => i.Name)
                                   .Distinct()
                                   .Select(i => new Language {
                Name = i
            });

            var allEntities = await GetAllAsync <Language>();

            var newEntities = distinctEntities
                              .Where(i => !allEntities.Any(j => j.Name == i.Name));

            using (var context = new DWHContext())
            {
                context.Set <Language>().AddRange(newEntities);
                await context.SaveChangesAsync();
            }
        }
示例#13
0
        public async Task UpsertAsync(List <ConversationTrack> entities)
        {
            var distinctEntities = entities
                                   .Select(i => i.ConversationId)
                                   .Distinct()
                                   .Select(i => new ConversationTrack {
                ConversationId = i
            });

            var allEntities = await GetAllAsync <ConversationTrack>();

            var newEntities = distinctEntities
                              .Where(i => !allEntities.Any(j => j.ConversationId == i.ConversationId));

            using (var context = new DWHContext())
            {
                context.Set <ConversationTrack>().AddRange(newEntities);
                await context.SaveChangesAsync();
            }
        }
示例#14
0
        public async Task UpsertAsync(List <TrendingTopic> entities)
        {
            var distinctEntities = entities
                                   .Select(i => new { i.Name, i.IsPromoted })
                                   .Distinct()
                                   .Select(i => new TrendingTopic {
                Name = i.Name, IsPromoted = i.IsPromoted
            });

            var allEntities = await GetAllAsync <TrendingTopic>();

            var newEntities = distinctEntities
                              .Where(i => !allEntities.Any(j => j.Name == i.Name));

            using (var context = new DWHContext())
            {
                context.Set <TrendingTopic>().AddRange(newEntities);
                await context.SaveChangesAsync();
            }
        }
示例#15
0
        public async Task UpsertAsync(List <SingleWord> entities)
        {
            var distinctEntities = entities
                                   .Select(i => i.Text)
                                   .Distinct()
                                   .Select(i => new SingleWord {
                Text = i
            });

            var allEntities = await GetAllAsync <SingleWord>();

            var newEntities = distinctEntities
                              .Where(i => !allEntities.Any(j => j.Text == i.Text));

            using (var context = new DWHContext())
            {
                context.Set <SingleWord>().AddRange(newEntities);
                await context.SaveChangesAsync();
            }
        }
示例#16
0
        public async Task UpsertAsync(List <User> entities)
        {
            var distinctEntities = entities
                                   .Select(i => new { i.UserId, i.Name })
                                   .Distinct()
                                   .Select(i => new User {
                UserId = i.UserId, Name = i.Name
            });

            var allEntities = await GetAllAsync <User>();

            var newEntities = distinctEntities
                              .Where(i => !allEntities.Any(j => j.UserId == i.UserId));

            using (var context = new DWHContext())
            {
                context.Set <User>().AddRange(newEntities);
                await context.SaveChangesAsync();
            }
        }