UserDefinedFunctionProvider.Invoke(String, Object[]) Method

Definition

Helper method to invoke User Defined Functions via Linq queries in the Azure Cosmos DB service.

public static object Invoke (string udfName, params object[] arguments);
static member Invoke : string * obj[] -> obj
Public Shared Function Invoke (udfName As String, ParamArray arguments As Object()) As Object

Parameters

udfName
String

the UserDefinedFunction name

arguments
Object[]

the arguments of the UserDefinedFunction

Returns

Examples


   await client.CreateUserDefinedFunctionAsync(collectionLink, new UserDefinedFunction { Id = "calculateTax", Body = @"function(amt) { return amt * 0.05; }" });
   var queryable = client.CreateDocumentQuery<Book>(collectionLink).Select(b => UserDefinedFunctionProvider.Invoke("calculateTax", b.Price));
   
  // Equivalent to SELECT * FROM books b WHERE udf.toLowerCase(b.title) = 'war and peace'" 
  await client.CreateUserDefinedFunctionAsync(collectionLink, new UserDefinedFunction { Id = "toLowerCase", Body = @"function(s) { return s.ToLowerCase(); }" });
  queryable = client.CreateDocumentQuery<Book>(collectionLink).Where(b => UserDefinedFunctionProvider.Invoke("toLowerCase", b.Title) == "war and peace");

Remarks

This is a stub helper method for use within LINQ expressions. Cannot be called directly.

Refer to http://azure.microsoft.com/documentation/articles/documentdb-sql-query/#linq-to-documentdb-sql for more details about the LINQ provider.

Refer to http://azure.microsoft.com/documentation/articles/documentdb-sql-query/#javascript-integration for more details about user defined functions.

Applies to

See also