Export (0) Print
Expand All

QueryAttribute Class

WCF RIA Services

[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 a DomainService method is a query method.

System.Object
  System.Attribute
    System.ServiceModel.DomainServices.Server.QueryAttribute

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

[AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false, 
	Inherited = true)]
public sealed class QueryAttribute : Attribute

The QueryAttribute type exposes the following members.

  NameDescription
Public methodQueryAttributeInitializes a new instance of the QueryAttribute class.
Top

  NameDescription
Public propertyHasSideEffectsGets or sets a value that indicates whether the query method has side effects.
Public propertyIsComposableGets or sets a value that indicates whether the query method allows query composition.
Public propertyIsDefaultGets or sets a value indicating whether the query method should be treated as the default query when multiple query methods are available.
Public propertyResultLimitGets or sets the maximum number of results a query operation should return.
Public propertyTypeId (Inherited from Attribute.)
Top

  NameDescription
Public methodEquals (Inherited from Attribute.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Attribute.)
Public methodGetType (Inherited from Object.)
Public methodIsDefaultAttribute (Inherited from Attribute.)
Public methodMatch (Inherited from Attribute.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Top

  NameDescription
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

You apply the QueryAttribute attribute to a method to indicate that the method is a query method, or to specify certain values for the query method. If your method matches the expected method signature for a query method, you do not have to apply the QueryAttribute. The RIA Services framework will infer that a method with the expected query signature should be treated as a query. You apply the IgnoreAttribute to a method to prevent the RIA Services framework from generating a domain operation for that method.

The following shows the expected signature for a query method:

Return value

IEnumerable<T>, IQueryable<T>, or entity

Parameters

Any number

Name Prefix

Any name

Attribute

[Query] (C#)

-or-

<Query()> (Visual Basic)

Example

public IQueryable<Product> GetProducts() (C#)

-or-

Public Function GetProducts() As IQueryable(Of Product) (Visual Basic)

The QueryAttribute class enables you to set values that are used when processing the query request. You set the ResultLimit property to limit how many records are returned for a query. You may want to set this value to prevent a user from burdening the server with large query requests. For more information, see Building Secure Applications with WCF RIA Services. The IsComposable property enables you to specify whether code in the client project can modify the results of the query by using the query method within a new query. For example, when IsComposable is true, you can add a Where clause in client code to a query on the server that returns all of the records from a database table.

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