Amend
|
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true)] public sealed class AmendExpressionAttribute : Attribute
The AmendExpressionAttribute type exposes the following members.
Name | Description | |
---|---|---|
AmendExpressionAttribute(String) | Creates a new AmendExpressionAttribute that will request application of amendmentText for any database. | |
AmendExpressionAttribute(String, DatabaseType) | Creates a new AmendExpressionAttribute that will request application of amendmentText for the specified targetDatabaseType. |
Name | Description | |
---|---|---|
AffixPosition | Gets or sets location for amendment application; defaults to Suffix. | |
AmendmentText | Gets or sets amendment text to be applied. | |
StatementTypes | Gets or sets statement types for amendment application; defaults to Select. | |
TargetDatabaseType | Gets target DatabaseType for amendment application. | |
TargetExpression | Gets or sets target expression for amendment application; defaults to TableName. | |
TypeId | When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute) |
Name | Description | |
---|---|---|
Equals | Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute) | |
GetHashCode | Returns the hash code for this instance. (Inherited from Attribute) | |
GetType | Gets the Type of the current instance. (Inherited from Object) | |
IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute) | |
Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute) | |
ToString | Returns a string that represents the current object. (Inherited from Object) |
Name | Description | |
---|---|---|
GetEnumValueOrDefault |
Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions) | |
GetEnumValueOrDefaultT |
Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions) |
As an example, this can be used to add table hints, e.g., WITH (NOLOCK), for select statements in SQL Server.
Applying the AmendExpressionAttribute to a modeled table with no specified database type parameter will be meant to infer that the amendment be used for all database types. Using a specific database type as a parameter to the attribute, e.g., [AmendExpression("WITH (NOLOCK)", DatabaseType.SQLServer)], means the amendment text will only be applied to the specific database - however, the attribute allows multiple instances on the same identifier so you could specify that amendment application only be applied to two databases:
[AmendExpression("AS T1", DatabaseType.SQLServer), AmendExpression("AS T1", DatabaseType.MySQL)]
[AmendExpression("TOP 200",
TargetExpression = TargetExpression.FieldList,
AffixPosition = AffixPosition.Prefix,
StatementTypes = StatementTypes.SelectSet)]