UserDefinedFunction Class

 

Updated: June 30, 2017

Represents a user defined function in the Azure DocumentDB database service.

Namespace:   Microsoft.Azure.Documents
Assembly:  Microsoft.Azure.Documents.Client (in Microsoft.Azure.Documents.Client.dll)

SystemObject
  Microsoft.Azure.DocumentsJsonSerializable
    Microsoft.Azure.DocumentsResource
      Microsoft.Azure.DocumentsUserDefinedFunction

No code example is currently available or this language may not be supported.

NameDescription
System_CAPS_pubmethodUserDefinedFunction

Initializes a new instance of the UserDefinedFunction class for the Azure DocumentDB database service.

NameDescription
System_CAPS_pubproperty

Gets the alt-link associated with the resource from the Azure DocumentDB database service. (Inherited from Resource.)

System_CAPS_pubproperty

Gets or sets the body of the user defined function for the Azure DocumentDB database service.

System_CAPS_pubproperty

Gets the entity tag associated with the resource from the Azure DocumentDB database service. (Inherited from Resource.)

System_CAPS_pubproperty

Gets or sets the Id of the resource in the Azure DocumentDB database service. (Inherited from Resource.)

System_CAPS_pubproperty

Gets or sets the Resource Id associated with the resource in the Azure DocumentDB database service. (Inherited from Resource.)

System_CAPS_pubproperty

Gets the self-link associated with the resource from the Azure DocumentDB database service. (Inherited from Resource.)

System_CAPS_pubproperty

Gets the last modified timestamp associated with the resource from the Azure DocumentDB database service. (Inherited from Resource.)

NameDescription
System_CAPS_pubmethodEquals

(Inherited from Object.)

System_CAPS_protmethodFinalize

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode

(Inherited from Object.)

System_CAPS_pubmethodGetPropertyValue

Gets property value associated with the specified property name from the Azure DocumentDB database service. (Inherited from Resource.)

System_CAPS_pubmethodGetType

(Inherited from Object.)

System_CAPS_pubmethodLoadFrom

Loads the object from the specified JSON reader in the Azure DocumentDB database service. (Inherited from JsonSerializable.)

System_CAPS_protmethodMemberwiseClone

(Inherited from Object.)

System_CAPS_pubmethodSaveTo

Saves the object to the specified stream in the Azure DocumentDB database service. (Inherited from JsonSerializable.)

System_CAPS_pubmethodSetPropertyValue

Sets property value associated with the specified property name in the Azure DocumentDB database service. (Inherited from Resource.)

System_CAPS_pubmethodToByteArray

Serialize to a byte array via SaveTo for the Azure DocumentDB database service. (Inherited from Resource.)

System_CAPS_pubmethodToString

Returns the string representation of the object in the Azure DocumentDB database service. (Inherited from JsonSerializable.)

NameDescription
System_CAPS_pubmethodIsDefined

Determines if a certain property is defined or not. (Defined by TypeCheckFunctionsExtensions.)

System_CAPS_pubmethodIsNull

Determines if a certain property is null or not. (Defined by TypeCheckFunctionsExtensions.)

System_CAPS_pubmethodIsPrimitive

Determines if a certain property is of premitive JSON type. (Defined by TypeCheckFunctionsExtensions.)

Azure DocumentDB supports JavaScript user defined functions (UDFs) which are stored in the database and can be used inside queries. Refer to http://azure.microsoft.com/documentation/articles/documentdb-sql-query/#javascript-integration for how to use UDFs within queries. Refer to http://azure.microsoft.com/documentation/articles/documentdb-programming/#udf for more details about implementing UDFs in JavaScript.

The following examples show how to register and use UDFs.


await client.CreateUserDefinedFunctionAsync(collectionLink, new UserDefinedFunction { Id = "calculateTax", Body = @"function(amt) { return amt * 0.05; }" });
client.CreateDocumentQuery<Book>(collectionLink, "SELECT VALUE udf.calculateTax(b.price) FROM books b");
client.CreateDocumentQuery<Book>(collectionLink, new SqlQuerySpec("SELECT VALUE udf.calculateTax(b.price) FROM books b"));
client.CreateDocumentQuery<Book>(collectionLink).Select(b => UserDefinedFunctionProvider.Invoke("calculateTax", b.Price));

await client.CreateUserDefinedFunctionAsync(collectionLink, new UserDefinedFunction { Id = "toLowerCase", Body = @"function(s) { return s.ToLowerCase(); }" });
client.CreateDocumentQuery<Book>(collectionLink, "SELECT * FROM books b WHERE b.toLowerCase = 'war and peace'");
client.CreateDocumentQuery<Book>(collectionLink, new SqlQuerySpec(
    "SELECT * FROM books b WHERE b.toLowerCase = @bookNameLowerCase",
    new SqlParameterCollection(new SqlParameter[] {new SqlParameter { Name = "@bookNameLowerCase", Value = "War And Peace".ToLower()
 }})));
 client.CreateDocumentQuery<Book>(collectionLink).Where(b => UserDefinedFunctionProvider.Invoke("toLowerCase", b.Title) == "war and peace");

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

Return to top
Show: