예제 #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();
 }
예제 #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();
        }
예제 #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);
        }
예제 #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();
        }
예제 #5
0
 public SearchContext(IApplicationConfiguration configuration)
 {
     _dataTools = new EntityFrameworkDataTools(configuration.ReadOnlyString);
 }