Created
April 15, 2018 17:49
-
-
Save NMZivkovic/7af7876ef21f5d2bbc3d7d8e5bc5bae9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Repository<TEntity> : IReporitory<TEntity> where TEntity : class | |
{ | |
protected readonly DbContext Context; | |
protected readonly DbSet<TEntity> Entities; | |
public Repository(DbContext context) | |
{ | |
Context = context; | |
Entities = Context.Set<TEntity>(); | |
} | |
public void Add(TEntity entity) | |
{ | |
Entities.Add(entity); | |
} | |
public void Remove(TEntity entity) | |
{ | |
Entities.Remove(entity); | |
} | |
public TEntity Get(int id) | |
{ | |
return Entities.Find(id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment