public IEnumerable <Author> GetAll()
        {
            var context = new BookstoreContext();
            var authors = context.Set <Author>().ToList();

            return(authors);
        }
        public IEnumerable <Book> GetAll()
        {
            var context = new BookstoreContext();
            var books   = context.Set <Book>().ToList();

            return(books);
        }
        public void Add(Author entity)
        {
            var context = new BookstoreContext();
            var dbSet   = context.Set <Author>();

            dbSet.Add(entity);
            context.SaveChanges();
        }
Exemple #4
0
 public T Insert(T item)
 {
     context.Set <T>().Add(item);
     context.SaveChanges();
     return(item);
 }
 public Repository(BookstoreContext ctx)
 {
     context = ctx;
     dbSet   = context.Set <T>();
 }
Exemple #6
0
 public virtual T Get(Guid id)
 {
     return(_contexto
            .Set <T>()
            .FirstOrDefault(x => x.Id == id));
 }