예제 #1
0
 public void Insert(T entity)
 {
     try
     {
         if (entity == null)
         {
             throw new ArgumentNullException("entity");
         }
         XiaoDbContext db = new XiaoDbContext();
         db.Set <T>().Add(entity);
         db.SaveChanges();
     }
     catch (System.Exception)
     {
         throw;
     }
 }
예제 #2
0
        public T GetById(object id)
        {
            XiaoDbContext db = new XiaoDbContext();

            return(db.Set <T>().Find(id));
        }