Delen via


SqlUserDefinedAggregateAttribute Class

Definition

Indicates that the type should be registered as a user-defined aggregate. The properties on the attribute reflect the physical attributes used when the type is registered with SQL Server. This class cannot be inherited.

public ref class SqlUserDefinedAggregateAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct, AllowMultiple=false, Inherited=false)]
public sealed class SqlUserDefinedAggregateAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct, AllowMultiple=false, Inherited=false)>]
type SqlUserDefinedAggregateAttribute = class
    inherit Attribute
Public NotInheritable Class SqlUserDefinedAggregateAttribute
Inherits Attribute
Inheritance
SqlUserDefinedAggregateAttribute
Attributes

Examples

The following example shows the SqlUserDefinedAggregateAttribute attribute for a user-defined aggregate. The aggregate uses custom serialization, has a maximum size of 8000 bytes when serialized, and is invariant to nulls, duplicates, and order.

using Microsoft.SqlServer.Server;
using System.IO;
using System.Data.Sql;
using System.Data.SqlTypes;
using System.Text;

[Serializable]
[Microsoft.SqlServer.Server.SqlUserDefinedAggregate(
   Microsoft.SqlServer.Server.Format.UserDefined,
   IsInvariantToNulls = true,
   IsInvariantToDuplicates = false,
   IsInvariantToOrder = false,
   MaxByteSize = 8000)
        ]
public class Concatenate : Microsoft.SqlServer.Server.IBinarySerialize
{

    public void Read(BinaryReader r)
    {

    }

    public void Write(BinaryWriter w)
    {

    }
}

Remarks

SQL Server creates a user-defined aggregate that is bound to the class definition that has the SqlUserDefinedAggregateAttribute custom attribute. Every user-defined aggregate must be annotated with this attribute.

See "CLR User-Defined Aggregates" in SQL Server 2005 Books Online for more information on user-defined aggregates and examples.

Constructors

SqlUserDefinedAggregateAttribute(Format)

A required attribute on a user-defined aggregate, used to indicate that the given type is a user-defined aggregate and the storage format of the user-defined aggregate.

Fields

MaxByteSizeValue

The maximum size, in bytes, required to store the state of this aggregate instance during computation.

Properties

Format

The serialization format as a Format.

IsInvariantToDuplicates

Indicates whether the aggregate is invariant to duplicates.

IsInvariantToNulls

Indicates whether the aggregate is invariant to nulls.

IsInvariantToOrder

Indicates whether the aggregate is invariant to order.

IsNullIfEmpty

Indicates whether the aggregate returns null if no values have been accumulated.

MaxByteSize

The maximum size, in bytes, of the aggregate instance.

Name

The name of the aggregate.

Applies to