Compartilhar via


ExcludeAttribute Class

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

Specifies that an entity member will not exist in the code-generated client view of the entity, and that the value should never be sent to the client.

Inheritance Hierarchy

System.Object
  System.Attribute
    System.ServiceModel.DomainServices.Server.ExcludeAttribute

Namespace:  System.ServiceModel.DomainServices.Server
Assembly:  System.ServiceModel.DomainServices.Server (in System.ServiceModel.DomainServices.Server.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple := False,  _
    Inherited := True)> _
Public NotInheritable Class ExcludeAttribute _
    Inherits Attribute
'Usage
Dim instance As ExcludeAttribute
[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false, 
    Inherited = true)]
public sealed class ExcludeAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Property|AttributeTargets::Field, AllowMultiple = false, 
    Inherited = true)]
public ref class ExcludeAttribute sealed : public Attribute
[<SealedAttribute>]
[<AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false, 
    Inherited = true)>]
type ExcludeAttribute =  
    class
        inherit Attribute
    end
public final class ExcludeAttribute extends Attribute

The ExcludeAttribute type exposes the following members.

Constructors

  Name Description
Public method ExcludeAttribute Initializes a new instance of the ExcludeAttribute class.

Top

Properties

  Name Description
Public property TypeId (Inherited from Attribute.)

Top

Methods

  Name Description
Public method Equals (Inherited from Attribute.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Attribute.)
Public method GetType (Inherited from Object.)
Public method IsDefaultAttribute (Inherited from Attribute.)
Public method Match (Inherited from Attribute.)
Protected method MemberwiseClone (Inherited from Object.)
Public method ToString (Inherited from Object.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method _Attribute.GetIDsOfNames (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfo (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfoCount (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.Invoke (Inherited from Attribute.)

Top

Remarks

You apply the ExcludeAttribute attribute to a property when you do not want to make the property available to client applications. Many values, such as identity values, are managed in the data source and do not need to be displayed or edited in the client.

Examples

The following example shows the ExcludeAttribute applied to property named rowguid which is of Guid type.

<MetadataTypeAttribute(GetType(Address.AddressMetadata))>  _
Partial Public Class Address

    Friend NotInheritable Class AddressMetadata

        'Metadata classes are not meant to be instantiated.
        Private Sub New()
            MyBase.New
        End Sub

        Public AddressID As Integer

        <Required()> _
        <StringLength(60)> _
        Public AddressLine1 As String

        Public AddressLine2 As String

        <Required()> _
        <StringLength(30)> _
        Public City As String

        Public CountryRegion As String

        Public CustomerAddresses As EntityCollection(Of CustomerAddress)

        Public ModifiedDate As DateTime

        <Required()> _
        Public PostalCode As String

        <Exclude()> _
        Public rowguid As Guid

        Public StateProvince As String
    End Class
End Class
[MetadataTypeAttribute(typeof(Address.AddressMetadata))]
public partial class Address
{

    internal sealed class AddressMetadata
    {
        // Metadata classes are not meant to be instantiated.
        private AddressMetadata()
        {
        }

        public int AddressID;

        [Required]
        [StringLength(60)]
        public string AddressLine1;

        public string AddressLine2;

        [Required]
        [StringLength(30)]
        public string City;

        public string CountryRegion;

        public EntityCollection<CustomerAddress> CustomerAddresses;

        public DateTime ModifiedDate;

        [Required]
        public string PostalCode;

        [Exclude]
        public Guid rowguid;

        public string StateProvince;
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.ServiceModel.DomainServices.Server Namespace