예제 #1
0
        public async Task <IEnumerable <T> > GetAll()
        {
            await using var context = _contextFactory.CreateDbContext(new[] { "" });
            var list = await context.Set <T>().ToListAsync();

            return(list);
        }
예제 #2
0
 public async Task <IEnumerable <T> > GetAll()
 {
     using (SimpleTraderDbContext context = _contextFactory.CreateDbContext())
     {
         return(await context.Set <T>().ToListAsync());
     }
 }
        public async Task <IEnumerable <Account> > GetAll()
        {
            using (SimpleTraderDbContext context = _contextFactory.CreateDbContext())
            {
                IEnumerable <Account> entities = await context.Accounts.Include(a => a.AssetTransactions).ToListAsync();

                return(entities);
            }
        }
예제 #4
0
        public async Task <T> Get(int id)
        {
            using (SimpleTraderDbContext context = _contextFactory.CreateDbContext())
            {
                T entity = await context.Set <T>().FirstOrDefaultAsync((e) => e.Id == id);

                return(entity);
            }
        }
예제 #5
0
        public async Task <T> Create(T entity)
        {
            using SimpleTraderDbContext context = _contextFactory.CreateDbContext();
            EntityEntry <T> createdResult = await context.Set <T>().AddAsync(entity);

            await context.SaveChangesAsync();

            return(createdResult.Entity);
        }
예제 #6
0
        public async Task <IEnumerable <T> > GetAll()
        {
            using (SimpleTraderDbContext context = _context.CreateDbContext())
            {
                IEnumerable <T> entities = await context.Set <T>().ToListAsync();

                return(entities);
            }
        }
예제 #7
0
        public async Task <Account> Get(int id)
        {
            using (SimpleTraderDbContext context = _contextFactory.CreateDbContext())
            {
                Account entity = await context.Accounts.Include(a => a.AssetTransactions).FirstOrDefaultAsync((e) => e.Id == id);

                return(entity);
            }
        }
예제 #8
0
        public async Task <T> Create(T entity)
        {
            await using var context = _contextFactory.CreateDbContext(new[] { "" });
            var createdEntity = await context.Set <T>().AddAsync(entity);

            await context.SaveChangesAsync();

            return(createdEntity.Entity);
        }
        public async Task <IEnumerable <T> > GetAll()
        {
            using (var context = _contextFactory.CreateDbContext())
            {
                IEnumerable <T> entities = await context.Set <T>().ToListAsync();

                return(entities);
            }
        }
예제 #10
0
        public async Task <IEnumerable <Account> > GetAll()
        {
            await using var context = _contextFactory.CreateDbContext(new[] { "" });
            var list = await context.Accounts
                       .Include(x => x.AccountHolder)
                       .Include(x => x.AssetTransactions).Include(x => x.AccountHolder)
                       .ToListAsync();

            return(list);
        }
예제 #11
0
        public async Task <T> Create(T entity)
        {
            using (SimpleTraderDbContext context = _contextFactory.CreateDbContext())
            {
                var createdEntity = await context.Set <T>().AddAsync(entity);

                await context.SaveChangesAsync();

                return(createdEntity.Entity);
            }
        }
예제 #12
0
        public async Task <T> Create(T entity)
        {
            using (var context = _contextFactory.CreateDbContext())
            {
                EntityEntry <T> createEntity = await context.Set <T>().AddAsync(entity);

                await context.SaveChangesAsync();

                return(createEntity.Entity);
            }
        }
예제 #13
0
        protected override void OnStartup(StartupEventArgs e)
        {
            _host.Start();

            SimpleTraderDbContextFactory contextFactory = _host.Services.GetRequiredService <SimpleTraderDbContextFactory>();

            using (SimpleTraderDbContext context = contextFactory.CreateDbContext())
            {
                context.Database.Migrate();
            }

            Window window = _host.Services.GetRequiredService <MainWindow>();

            window.Show();

            base.OnStartup(e);
        }