示例#1
0
 public void handleInsert(BOOK entity)
 {
     try
     {
         db.BOOKS.Add(entity);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         Console.WriteLine("Error: \n" + e);
     }
 }
示例#2
0
        public void handleUpdate(BOOK entity)
        {
            var udObj = db.BOOKS.SingleOrDefault(x => x.ID == entity.ID);

            udObj.IN_LIB    = entity.IN_LIB;
            udObj.OUT_LIB   = entity.OUT_LIB;
            udObj.NAME      = entity.NAME;
            udObj.PUBLISHER = entity.PUBLISHER;
            udObj.AUTHOR    = entity.AUTHOR;
            udObj.CONTENT   = entity.CONTENT;
            udObj.COST      = entity.COST;
            udObj.COVER     = entity.COVER != null ? entity.COVER : udObj.COVER;
            db.SaveChanges();
        }