Пример #1
0
            public int Delete(ExampleDBModel exampleDBModel)
            {
                string sql = @"DELETE FROM [dbo].[ExampleDBModel]
                                WHERE [Currently Employed] = @CurrentlyEmployed";

                return(ExecuteSql(sql, exampleDBModel));
            }
Пример #2
0
 private int ExecuteSql(string sql, ExampleDBModel exampleDBModel)
 {
     using (var dbconnection = new SqlConnection(_connectionString))
     {
         dbconnection.Open();
         var transaction = dbconnection.BeginTransaction();
         try
         {
             var response = dbconnection.Execute(sql, exampleDBModel);
             transaction.Commit();
             return(response);
         }
         catch
         {
             transaction.Rollback();
             throw;
         }
     }
 }
Пример #3
0
            public int Insert(ExampleDBModel exampleDBModel)
            {
                string sql = @"INSERT INTO [dbo].[ExampleDBModel]
                                ([Name],[DoB],[Office Location],[Currently Employed],[Salary]
                               VALUES (@Name, @DoB @OfficeLocation, @CurrentlyEmployed, @Salary)";

                using (var dbconnection = new SqlConnection(_connectionString))
                {
                    dbconnection.Open();
                    var transaction = dbconnection.BeginTransaction();
                    try
                    {
                        var response = dbconnection.Execute(sql, exampleDBModel);
                        transaction.Commit();
                        return(response);
                    }
                    catch
                    {
                        transaction.Rollback();
                        throw;
                    }
                }
            }
Пример #4
0
 public int Update(ExampleDBModel exampleDBModel)
 {
     return(Update(new SQLQuery <ExampleDBModel>(_updateQuery, exampleDBModel)));
 }
Пример #5
0
 public int Delete(ExampleDBModel exampleDBModel)
 {
     return(Delete(new SQLQuery <ExampleDBModel>(_deleteQuery, exampleDBModel)));
 }
Пример #6
0
 public int Insert(ExampleDBModel exampleDBModel)
 {
     return(Insert(new SQLQuery <ExampleDBModel>(_insertQuery, exampleDBModel)));
 }