Permalink
Fetching contributors…
Cannot retrieve contributors at this time
160 lines (151 sloc) 11 KB
<Type Name="UserDefinedFunctionProvider" FullName="Microsoft.Azure.Documents.Linq.UserDefinedFunctionProvider">
<TypeSignature Language="C#" Value="public static class UserDefinedFunctionProvider" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed beforefieldinit UserDefinedFunctionProvider extends System.Object" />
<TypeSignature Language="DocId" Value="T:Microsoft.Azure.Documents.Linq.UserDefinedFunctionProvider" />
<AssemblyInfo>
<AssemblyName>Microsoft.Azure.Documents.Client</AssemblyName>
<AssemblyVersion>1.14.0.0</AssemblyVersion>
<AssemblyVersion>1.16.0.0</AssemblyVersion>
<AssemblyVersion>1.17.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>Microsoft.Azure.DocumentDB.Core</AssemblyName>
<AssemblyVersion>1.5.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>
Helper class to invoke User Defined Functions via Linq queries in the Azure DocumentDB database service.
</summary>
<remarks>To be added.</remarks>
</Docs>
<Members>
<Member MemberName="Invoke">
<MemberSignature Language="C#" Value="public static object Invoke (string udfName, object[] arguments);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig object Invoke(string udfName, object[] arguments) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.Azure.Documents.Linq.UserDefinedFunctionProvider.Invoke(System.String,System.Object[])" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.Azure.Documents.Client</AssemblyName>
<AssemblyVersion>1.14.0.0</AssemblyVersion>
<AssemblyVersion>1.16.0.0</AssemblyVersion>
<AssemblyVersion>1.17.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>Microsoft.Azure.DocumentDB.Core</AssemblyName>
<AssemblyVersion>1.5.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="udfName" Type="System.String" />
<Parameter Name="arguments" Type="System.Object[]">
<Attributes>
<Attribute>
<AttributeName>System.ParamArray</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="udfName">the UserDefinedFunction name</param>
<param name="arguments">the arguments of the UserDefinedFunction</param>
<summary>
Helper method to invoke User Defined Functions via Linq queries in the Azure DocumentDB database service.
</summary>
<returns />
<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.
</remarks>
<example>
<code language="c#"><![CDATA[
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");
]]></code>
</example>
<altmember cref="T:Microsoft.Azure.Documents.UserDefinedFunction" />
<example>
<code language="c#"><![CDATA[
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");
]]></code>
</example>
<example>
<code language="c#"><![CDATA[
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");
]]></code>
</example>
<example>
<code language="c#"><![CDATA[
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");
]]></code>
</example>
<example>
<code language="c#"><![CDATA[
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");
]]></code>
</example>
<example>
<code language="c#"><![CDATA[
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");
]]></code>
</example>
<example>
<code language="c#"><![CDATA[
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");
]]></code>
</example>
<example>
<code language="c#"><![CDATA[
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");
]]></code>
</example>
<example>
<code language="c#"><![CDATA[
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");
]]></code>
</example>
</Docs>
</Member>
</Members>
</Type>