Пример #1
0
 public bool Update(IOpstiDomenskiObjekat objekat)
 {
     try
     {
         connection.Open();
         transaction = connection.BeginTransaction();
         SqlCommand command = new SqlCommand();
         command.Connection  = connection;
         command.Transaction = transaction;
         command.CommandText = $"update {objekat.Table()} set {objekat.Update()}  {objekat.Where()}";
         if (command.ExecuteNonQuery() == 0)
         {
             throw new Exception();
         }
         transaction.Commit();
         return(true);
     }
     catch (Exception e)
     {
         transaction.Rollback();
         Console.WriteLine(e.Message);
         return(false);
     }
     finally
     {
         connection.Close();
     }
 }