Example #1
0
        public async Task <bool> DeleteAsync(string id)
        {
            // This is a slick method to delete without a lookup but if the entity exists in the
            // context's tracked entities it throws. Therefore, use a new context object.
            using (var context = new TrackItContext(Configuration))
            {
                var entity = new T();
                entity.Id = id;
                context.Attach(entity);
                context.Remove(entity);
                var saveCount = await context.SaveChangesAsync();

                return(saveCount > 0);
            }
        }
Example #2
0
 public Repository(IDbConfiguration configuration)
 {
     Configuration = configuration;
     Context       = new TrackItContext(Configuration);
 }