Class ThrowHelper
- Namespace
- RentADeveloper.DbConnectionPlus
- Assembly
- RentADeveloper.DbConnectionPlus.dll
Provides methods to throw common exceptions.
public static class ThrowHelper
- Inheritance
-
ThrowHelper
- Inherited Members
Methods
ThrowConfigurationIsFrozenException()
Throws an InvalidOperationException indicating that the configuration of DbConnectionPlus is frozen and can no longer be modified.
[DoesNotReturn]
public static void ThrowConfigurationIsFrozenException()
Exceptions
- InvalidOperationException
Always thrown.
ThrowDatabaseAdapterDoesNotSupportTemporaryTablesException(IDatabaseAdapter)
Throws an NotSupportedException indicating that an attempt was made to use the temporary tables feature of DbConnectionPlus, but the database adapter for the current database system does not support temporary tables.
[DoesNotReturn]
public static void ThrowDatabaseAdapterDoesNotSupportTemporaryTablesException(IDatabaseAdapter databaseAdapter)
Parameters
databaseAdapterIDatabaseAdapterThe database adapter that does not support temporary tables.
Exceptions
- NotSupportedException
Always thrown.
ThrowDatabaseOperationAffectedUnexpectedNumberOfRowsException(int, int, object)
Throws an DbUpdateConcurrencyException indicating that a concurrency violation was encountered while deleting or updating an entity in a database. A concurrency violation occurs when an unexpected number of rows are affected by a delete or update operation. This is usually because the data in the database has been modified since the entity has been loaded.
[DoesNotReturn]
public static void ThrowDatabaseOperationAffectedUnexpectedNumberOfRowsException(int expectedNumberOfAffectedRows, int actualNumberOfAffectedRows, object entity)
Parameters
expectedNumberOfAffectedRowsintThe expected number of affected rows.
actualNumberOfAffectedRowsintThe actual number of affected rows.
entityobjectThe entity that was involved in the operation.
Exceptions
- DbUpdateConcurrencyException
Always thrown.
ThrowEntityTypeHasNoKeyPropertyException(Type)
Throws an ArgumentException indicating that the specified entity type has no key property.
[DoesNotReturn]
public static void ThrowEntityTypeHasNoKeyPropertyException(Type entityType)
Parameters
entityTypeTypeThe entity type that lacks a key property.
Exceptions
- ArgumentException
Always thrown.
ThrowInvalidEnumSerializationModeException<T>(EnumSerializationMode)
Throws an ArgumentOutOfRangeException indicating that the specified EnumSerializationMode is invalid.
[DoesNotReturn]
public static T ThrowInvalidEnumSerializationModeException<T>(EnumSerializationMode enumSerializationMode)
Parameters
enumSerializationModeEnumSerializationModeThe EnumSerializationMode value that is invalid.
Returns
- T
Type Parameters
TThe type parameter for the return value of this method. This just exists to satisfy the compiler when this method is used in an expression or when we must trick the compiler to believe a value is returned.
Exceptions
- ArgumentOutOfRangeException
Always thrown.
ThrowSqlStatementReturnedMoreThanOneRowException()
Throws an InvalidOperationException indicating that an SQL statement did return more than one row when it was expected to return just one.
[DoesNotReturn]
public static void ThrowSqlStatementReturnedMoreThanOneRowException()
Exceptions
- InvalidOperationException
Always thrown.
ThrowSqlStatementReturnedNoRowsException()
Throws an InvalidOperationException indicating that an SQL statement did not return any rows when it was expected to.
[DoesNotReturn]
public static void ThrowSqlStatementReturnedNoRowsException()
Exceptions
- InvalidOperationException
Always thrown.
ThrowWrongConnectionTypeException<TExpectedConnectionType, T>()
Throws an ArgumentOutOfRangeException indicating that the specified connection is not of the expected type.
[DoesNotReturn]
public static T ThrowWrongConnectionTypeException<TExpectedConnectionType, T>() where TExpectedConnectionType : DbConnection
Returns
- T
Type Parameters
TExpectedConnectionTypeThe type of connection that was expected.
TThe type parameter for the return value of this method. This just exists to satisfy the compiler when this method is used in an expression or when we must trick the compiler to believe a value is returned.
Exceptions
- ArgumentOutOfRangeException
Always thrown.
ThrowWrongTransactionTypeException<TExpectedTransactionType, T>()
Throws an ArgumentOutOfRangeException indicating that the specified transaction is not of the expected type.
[DoesNotReturn]
public static T ThrowWrongTransactionTypeException<TExpectedTransactionType, T>() where TExpectedTransactionType : DbTransaction
Returns
- T
Type Parameters
TExpectedTransactionTypeThe type of transaction that was expected.
TThe type parameter for the return value of this method. This just exists to satisfy the compiler when this method is used in an expression or when we must trick the compiler to believe a value is returned.
Exceptions
- ArgumentOutOfRangeException
Always thrown.