Example #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;
     }
 }
Example #2
0
        public T GetById(object id)
        {
            XiaoDbContext db = new XiaoDbContext();

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