public T SelectById(object id)
 {
     using (WorldMapDBContext context = new WorldMapDBContext())
     {
         DbSet <T> table = context.Set <T>();
         return(table.Find(id));
     }
 }
 public List <T> SelectAll()
 {
     using (WorldMapDBContext context = new WorldMapDBContext())
     {
         DbSet <T> table = context.Set <T>();
         return(table.ToList());
     }
 }
 public void Update(T entity)
 {
     using (WorldMapDBContext context = new WorldMapDBContext())
     {
         DbSet <T> table = context.Set <T>();
         table.Attach(entity);
         context.Entry(entity).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
 public List <T> Search(Expression <Func <T, bool> > filter = null)
 {
     using (WorldMapDBContext context = new WorldMapDBContext())
     {
         if (filter == null)
         {
             return(context.Set <T>().ToList <T>());
         }
         return(context.Set <T>().Where <T>(filter).ToList <T>());
     }
 }
        public DbSet <T> GetEntites()
        {
            WorldMapDBContext context = new WorldMapDBContext();

            return(context.Set <T>());
        }
Esempio n. 6
0
 public WorldMapDBContext Init()
 {
     return(dbContext ?? (dbContext = new WorldMapDBContext()));
 }