public void ExecuteDeleteStoredProcedure([NotNull] IBaseDataItem dataItem) { var id = dataItem.GetId(); if (id == 0) { return; } var database = GetDatabase(); using (var dbCommand = database.GetStoredProcCommand(dataItem.DeleteStoredProcedure)) { database.AddInParameter(dbCommand, dataItem.AutoIdField, DbType.Int32, dataItem.GetId()); database.ExecuteNonQuery(dbCommand); } }
private static void SetParameterData([NotNull] IBaseDataItem dataItem, [NotNull] Database database, DbCommand dbCommand) { // autoidfield database.AddParameter(dbCommand, dataItem.AutoIdField, DbType.Int32, ParameterDirection.InputOutput, dataItem.AutoIdField, DataRowVersion.Proposed, dataItem.GetId()); // fields changing at the database side foreach (var parameterObject in dataItem.AutoUpdateFieldDictionary.Values) { database.AddParameter(dbCommand, parameterObject.ParameterName, parameterObject.DbType, ParameterDirection.InputOutput, parameterObject.ParameterName, DataRowVersion.Proposed, parameterObject.Value); } // all the other fields foreach (var parameterObject in dataItem.SetItemData()) { database.AddInParameter(dbCommand, parameterObject.ParameterName, parameterObject.DbType, parameterObject.Value); } }