예제 #1
0
 public async Task <IReadOnlyList <User> > ListAsync(IQueryableSpecification <User> specification = null)
 {
     using (var ctx = new EntityFrameworkContext(_options)) {
         var query = ctx.Users as IQueryable <User>;
         if (specification != null)
         {
             query = query.Where(specification.Predicate);
         }
         return(await query.ToListAsync().ConfigureAwait(false));
     }
 }
예제 #2
0
        public EntityFrameworkRepository()
        {
            _connection = new SqlConnection("Server=(localdb)\\mssqllocaldb;Integrated Security=true;");
            _connection.Open();

            _options = new DbContextOptionsBuilder <EntityFrameworkContext>()
                       .UseSqlServer(_connection)
                       .Options;

            using (var context = new EntityFrameworkContext(_options)) {
                context.Database.EnsureCreated();
            }
        }