Click or drag to resize

AmendExpressionAttribute Class

Defines an attribute that will request amendment of a table name or field list with the specified text.
Inheritance Hierarchy
SystemObject
  SystemAttribute
    GSF.Data.ModelAmendExpressionAttribute

Namespace: GSF.Data.Model
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.207-beta+1781b796b2aa7a54013a031eb432fe4ccee31867
Syntax
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true)]
public sealed class AmendExpressionAttribute : Attribute
View Source

The AmendExpressionAttribute type exposes the following members.

Constructors
 NameDescription
Public methodAmendExpressionAttribute(String) Creates a new AmendExpressionAttribute that will request application of amendmentText for any database.
Public methodAmendExpressionAttribute(String, DatabaseType) Creates a new AmendExpressionAttribute that will request application of amendmentText for the specified targetDatabaseType.
Top
Properties
 NameDescription
Public propertyAffixPosition Gets or sets location for amendment application; defaults to Suffix.
Public propertyAmendmentText Gets or sets amendment text to be applied.
Public propertyStatementTypes Gets or sets statement types for amendment application; defaults to Select.
Public propertyTargetDatabaseType Gets target DatabaseType for amendment application.
Public propertyTargetExpression Gets or sets target expression for amendment application; defaults to TableName.
Public propertyTypeIdWhen implemented in a derived class, gets a unique identifier for this Attribute.
(Inherited from Attribute)
Top
Methods
 NameDescription
Public methodEqualsReturns a value that indicates whether this instance is equal to a specified object.
(Inherited from Attribute)
Public methodGetHashCodeReturns the hash code for this instance.
(Inherited from Attribute)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodIsDefaultAttributeWhen overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
(Inherited from Attribute)
Public methodMatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
(Inherited from Attribute)
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Extension Methods
 NameDescription
Public Extension MethodGetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Public Extension MethodGetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Top
Remarks

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:

C#
[AmendExpression("AS T1", DatabaseType.SQLServer), AmendExpression("AS T1", DatabaseType.MySQL)]
Other parameters exist to fully customize target expression, set affix position and specify statement types:
C#
[AmendExpression("TOP 200",
    TargetExpression = TargetExpression.FieldList,
    AffixPosition = AffixPosition.Prefix,
    StatementTypes = StatementTypes.SelectSet)]

See Also