Ejemplo n.º 1
0
 public async Task ModifyModel <T>(T original, T model) where T : class, IDataModel
 {
     using var ctx = new EntityFrameworkDataTools(_configuration.ReadWriteConnectionString);
     ctx.Attach(model);
     ctx.Entry(model).State = EntityState.Modified;
     await ctx.SaveChangesAsync();
 }
Ejemplo n.º 2
0
        public async Task AddModel <T>(T model) where T : class, IDataModel
        {
            using var ctx = new EntityFrameworkDataTools(_configuration.ReadWriteConnectionString);
            await ctx.AddAsync(model);

            await ctx.SaveChangesAsync();
        }
Ejemplo n.º 3
0
        public async Task <T> GetModel <T>(Guid id) where T : class, IDataModel
        {
            using var ctx = new EntityFrameworkDataTools(_configuration.ReadWriteConnectionString);
            var rtn = await ctx.FindAsync <T>(id);

            return(rtn);
        }
Ejemplo n.º 4
0
        public async Task RemoveModel <T>(Guid id) where T : class, IDataModel
        {
            using var ctx = new EntityFrameworkDataTools(_configuration.ReadWriteConnectionString);
            var model = await ctx.FindAsync <T>(id);

            ctx.Remove(model);
            await ctx.SaveChangesAsync();
        }
Ejemplo n.º 5
0
 public SearchContext(IApplicationConfiguration configuration)
 {
     _dataTools = new EntityFrameworkDataTools(configuration.ReadOnlyString);
 }