Коммит
f9bae93023
|
@ -44,8 +44,8 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.9.2\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
|
@ -83,7 +83,9 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -108,8 +108,12 @@
|
|||
{
|
||||
DocumentCollection simpleCollection = await CreateCollection();
|
||||
|
||||
await CreatePartitionedCollection();
|
||||
|
||||
await CreateCollectionWithCustomIndexingPolicy();
|
||||
|
||||
await CreateCollectionWithTtlExpiration();
|
||||
|
||||
await GetAndChangeCollectionPerformance(simpleCollection);
|
||||
|
||||
await ReadCollectionProperties();
|
||||
|
@ -132,6 +136,25 @@
|
|||
return simpleCollection;
|
||||
}
|
||||
|
||||
private static async Task<DocumentCollection> CreatePartitionedCollection()
|
||||
{
|
||||
// Define "deviceId" as the partition key
|
||||
// Set throughput to the minimum value of 10,100 RU/s
|
||||
|
||||
DocumentCollection collectionDefinition = new DocumentCollection();
|
||||
collectionDefinition.Id = "PartitionedCollection";
|
||||
collectionDefinition.PartitionKey.Paths.Add("/deviceId");
|
||||
|
||||
DocumentCollection partitionedCollection = await client.CreateDocumentCollectionAsync(
|
||||
UriFactory.CreateDatabaseUri(databaseName),
|
||||
collectionDefinition,
|
||||
new RequestOptions { OfferThroughput = 10100 });
|
||||
|
||||
Console.WriteLine("\n1.1. Created Collection \n{0}", partitionedCollection);
|
||||
|
||||
return partitionedCollection;
|
||||
}
|
||||
|
||||
private static async Task CreateCollectionWithCustomIndexingPolicy()
|
||||
{
|
||||
// Create a collection with custom index policy (lazy indexing)
|
||||
|
@ -147,6 +170,20 @@
|
|||
|
||||
Console.WriteLine("1.2. Created Collection {0}, with custom index policy \n{1}", collectionWithLazyIndexing.Id, collectionWithLazyIndexing.IndexingPolicy);
|
||||
}
|
||||
|
||||
private static async Task CreateCollectionWithTtlExpiration()
|
||||
{
|
||||
DocumentCollection collectionDefinition = new DocumentCollection();
|
||||
collectionDefinition.Id = "TtlExpiryCollection";
|
||||
collectionDefinition.DefaultTimeToLive = 60 * 60 * 24; //expire in 1 day
|
||||
|
||||
DocumentCollection ttlEnabledCollection = await client.CreateDocumentCollectionAsync(
|
||||
UriFactory.CreateDatabaseUri(databaseName),
|
||||
collectionDefinition,
|
||||
new RequestOptions { OfferThroughput = 400 });
|
||||
|
||||
Console.WriteLine("\n1.3. Created Collection \n{0} with TTL expiration of {1}", ttlEnabledCollection.Id, ttlEnabledCollection.DefaultTimeToLive);
|
||||
}
|
||||
|
||||
private static async Task GetAndChangeCollectionPerformance(DocumentCollection simpleCollection)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.6.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.9.2" targetFramework="net451" />
|
||||
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
|
||||
</packages>
|
|
@ -44,8 +44,8 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.9.2\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
|
@ -85,7 +85,9 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.6.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.9.2" targetFramework="net451" />
|
||||
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
|
||||
</packages>
|
|
@ -44,8 +44,8 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.9.2\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
|
@ -88,7 +88,9 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
namespace DocumentDB.Samples.DocumentManagement
|
||||
{
|
||||
using DocumentDB.Samples.Shared;
|
||||
using Shared;
|
||||
using Microsoft.Azure.Documents;
|
||||
using Microsoft.Azure.Documents.Client;
|
||||
using Microsoft.Azure.Documents.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
|
@ -55,32 +50,39 @@
|
|||
|
||||
public class Program
|
||||
{
|
||||
//Read config
|
||||
// Read config
|
||||
private static readonly string endpointUrl = ConfigurationManager.AppSettings["EndPointUrl"];
|
||||
private static readonly string authorizationKey = ConfigurationManager.AppSettings["AuthorizationKey"];
|
||||
private static readonly string databaseName = ConfigurationManager.AppSettings["DatabaseId"];
|
||||
private static readonly string collectionName = ConfigurationManager.AppSettings["CollectionId"];
|
||||
private static readonly ConnectionPolicy connectionPolicy = new ConnectionPolicy { UserAgentSuffix = " samples-net/3" };
|
||||
|
||||
//Reusable instance of DocumentClient which represents the connection to a DocumentDB endpoint
|
||||
private static DocumentClient client;
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
//Get a single instance of Document client and reuse this for all the samples
|
||||
//This is the recommended approach for DocumentClient as opposed to new'ing up new instances each time
|
||||
using (client = new DocumentClient(new Uri(endpointUrl), authorizationKey))
|
||||
ConnectionPolicy connectionPolicy = new ConnectionPolicy();
|
||||
connectionPolicy.UserAgentSuffix = " samples-net/3";
|
||||
connectionPolicy.ConnectionMode = ConnectionMode.Direct;
|
||||
connectionPolicy.ConnectionProtocol = Protocol.Tcp;
|
||||
|
||||
// Set the read region selection preference order
|
||||
connectionPolicy.PreferredLocations.Add(LocationNames.EastUS); // first preference
|
||||
connectionPolicy.PreferredLocations.Add(LocationNames.NorthEurope); // second preference
|
||||
connectionPolicy.PreferredLocations.Add(LocationNames.SoutheastAsia); // third preference
|
||||
|
||||
using (client = new DocumentClient(new Uri(endpointUrl), authorizationKey, connectionPolicy))
|
||||
{
|
||||
//ensure the database & collection exist before running samples
|
||||
Initialize().Wait();
|
||||
|
||||
RunDocumentsDemo().Wait();
|
||||
|
||||
//Clean-up environment
|
||||
Cleanup();
|
||||
}
|
||||
}
|
||||
#if !DEBUG
|
||||
catch (DocumentClientException de)
|
||||
{
|
||||
Exception baseException = de.GetBaseException();
|
||||
|
@ -91,9 +93,10 @@
|
|||
Exception baseException = e.GetBaseException();
|
||||
Console.WriteLine("Error: {0}, Message: {1}", e.Message, baseException.Message);
|
||||
}
|
||||
#endif
|
||||
finally
|
||||
{
|
||||
Console.WriteLine("\nEnd of demo, press any key to exit.");
|
||||
Console.WriteLine("End of demo, press any key to exit.");
|
||||
Console.ReadKey();
|
||||
}
|
||||
}
|
||||
|
@ -138,19 +141,19 @@
|
|||
|
||||
private static async Task CreateDocumentsAsync()
|
||||
{
|
||||
Uri collectionLink = UriFactory.CreateDocumentCollectionUri(databaseName, collectionName);
|
||||
Uri collectionUri = UriFactory.CreateDocumentCollectionUri(databaseName, collectionName);
|
||||
|
||||
Console.WriteLine("\n1.1 - Creating documents");
|
||||
|
||||
// Create a SalesOrder object. This object has nested properties and various types including numbers, DateTimes and strings.
|
||||
// This can be saved as JSON as is without converting into rows/columns.
|
||||
SalesOrder salesOrder = GetSalesOrderSample("SalesOrder1");
|
||||
await client.CreateDocumentAsync(collectionLink, salesOrder);
|
||||
await client.CreateDocumentAsync(collectionUri, salesOrder);
|
||||
|
||||
// As your app evolves, let's say your object has a new schema. You can insert SalesOrderV2 objects without any
|
||||
// changes to the database tier.
|
||||
SalesOrder2 newSalesOrder = GetSalesOrderV2Sample("SalesOrder2");
|
||||
await client.CreateDocumentAsync(collectionLink, newSalesOrder);
|
||||
await client.CreateDocumentAsync(collectionUri, newSalesOrder);
|
||||
}
|
||||
|
||||
private static async Task ReadDocumentAsync()
|
||||
|
@ -185,6 +188,7 @@
|
|||
Console.WriteLine(document);
|
||||
}
|
||||
}
|
||||
|
||||
private static SalesOrder QueryDocuments()
|
||||
{
|
||||
//******************************************************************************************************************
|
||||
|
@ -212,6 +216,7 @@
|
|||
|
||||
return querySalesOrder;
|
||||
}
|
||||
|
||||
private static async Task ReplaceDocumentAsync(SalesOrder order)
|
||||
{
|
||||
//******************************************************************************************************************
|
||||
|
@ -230,6 +235,7 @@
|
|||
Console.WriteLine("Request charge of replace operation: {0}", response.RequestCharge);
|
||||
Console.WriteLine("Shipped date of updated document: {0}", updated.GetPropertyValue<DateTime>("ShippedDate"));
|
||||
}
|
||||
|
||||
private static async Task UpsertDocumentAsync()
|
||||
{
|
||||
Console.WriteLine("\n1.6 - Upserting a document");
|
||||
|
@ -252,6 +258,7 @@
|
|||
Console.WriteLine("Id of upserted document: {0}", upserted.Id);
|
||||
Console.WriteLine("AccountNumber of upserted document: {0}", upserted.GetPropertyValue<string>("AccountNumber"));
|
||||
}
|
||||
|
||||
private static async Task DeleteDocumentAsync()
|
||||
{
|
||||
Console.WriteLine("\n1.7 - Deleting a document");
|
||||
|
@ -265,7 +272,7 @@
|
|||
|
||||
private static SalesOrder GetSalesOrderSample(string documentId)
|
||||
{
|
||||
return new SalesOrder
|
||||
SalesOrder salesOrder = new SalesOrder
|
||||
{
|
||||
Id = documentId,
|
||||
AccountNumber = "Account1",
|
||||
|
@ -286,7 +293,13 @@
|
|||
}
|
||||
},
|
||||
};
|
||||
|
||||
// Set the "ttl" property to auto-expire sales orders in 30 days
|
||||
salesOrder.TimeToLive = 60 * 60 * 24 * 30;
|
||||
|
||||
return salesOrder;
|
||||
}
|
||||
|
||||
private static SalesOrder2 GetSalesOrderV2Sample(string documentId)
|
||||
{
|
||||
return new SalesOrder2
|
||||
|
@ -320,7 +333,6 @@
|
|||
|
||||
/// <summary>
|
||||
/// 2. Basic CRUD operations using dynamics instead of strongly typed objects
|
||||
///
|
||||
/// DocumentDB does not require objects to be typed. Applications that merge data from different data sources, or
|
||||
/// need to handle evolving schemas can write data directly as JSON or dynamic objects.
|
||||
/// </summary>
|
||||
|
@ -363,7 +375,6 @@
|
|||
salesOrder.foo = "bar";
|
||||
|
||||
//now do a replace using this dynamic document
|
||||
//notice here you don't have to set collectionLink, or documentSelfLink,
|
||||
//everything that is needed is contained in the readDynOrder object
|
||||
//it has a .self Property
|
||||
Console.WriteLine("\nReplacing document");
|
||||
|
@ -383,7 +394,6 @@
|
|||
/// <returns></returns>
|
||||
private static async Task UseETags()
|
||||
{
|
||||
|
||||
//******************************************************************************************************************
|
||||
// 3.1 - Use ETag to control if a replace should succeed, or not, based on whether the ETag on the requst matches
|
||||
// the current ETag value of the persisted Document
|
||||
|
@ -432,14 +442,15 @@
|
|||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
// 3.2 - ETag on a ReadDcoumentAsync request can be used to tell the server whether it should return a result, or not
|
||||
// 3.2 - ETag on a ReadDocumentAsync request can be used to tell the server whether it should return a result, or not
|
||||
//
|
||||
// By setting the ETag on a ReadDocumentRequest along with an AccessCondition of IfNoneMatch instructs the server
|
||||
// to only return a result if the ETag of the request does not match that of the persisted Document
|
||||
//*******************************************************************************************************************
|
||||
|
||||
Console.WriteLine("\n3.2 - Using ETag to do a conditional ReadDocumentAsync");
|
||||
|
||||
//get a document
|
||||
// Get a document
|
||||
var response = await client.ReadDocumentAsync(
|
||||
UriFactory.CreateDocumentUri(databaseName, collectionName, "SalesOrder2"),
|
||||
new RequestOptions { PartitionKey = new PartitionKey("Account2") });
|
||||
|
@ -447,7 +458,7 @@
|
|||
readDoc = response.Resource;
|
||||
Console.WriteLine("Read doc with StatusCode of {0}", response.StatusCode);
|
||||
|
||||
//get the document again with conditional access set, no document should be returned
|
||||
// Get the document again with conditional access set, no document should be returned
|
||||
var accessCondition = new AccessCondition
|
||||
{
|
||||
Condition = readDoc.ETag,
|
||||
|
@ -464,7 +475,7 @@
|
|||
|
||||
Console.WriteLine("Read doc with StatusCode of {0}", response.StatusCode);
|
||||
|
||||
//now change something on the document, then do another get and this time we should get the document back
|
||||
// Now change something on the document, then do another get and this time we should get the document back
|
||||
readDoc.SetPropertyValue("foo", "updated");
|
||||
response = await client.ReplaceDocumentAsync(readDoc);
|
||||
|
||||
|
@ -512,6 +523,7 @@
|
|||
collectionDefinition,
|
||||
new RequestOptions { OfferThroughput = 1000 });
|
||||
}
|
||||
|
||||
private static async Task<Database> DeleteDatabaseIfExists(string databaseId)
|
||||
{
|
||||
var databaseUri = UriFactory.CreateDatabaseUri(databaseId);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.6.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.9.2" targetFramework="net451" />
|
||||
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
|
||||
</packages>
|
|
@ -44,8 +44,8 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.9.2\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
|
@ -88,7 +88,9 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.6.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.9.2" targetFramework="net451" />
|
||||
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
|
||||
</packages>
|
|
@ -44,8 +44,8 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.9.2\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
|
@ -86,7 +86,9 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.6.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.9.2" targetFramework="net451" />
|
||||
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
|
||||
</packages>
|
|
@ -43,7 +43,8 @@
|
|||
try
|
||||
{
|
||||
//Get a Document client
|
||||
using (client = new DocumentClient(new Uri(endpointUrl), authorizationKey))
|
||||
using (client = new DocumentClient(new Uri(endpointUrl), authorizationKey,
|
||||
new ConnectionPolicy { ConnectionMode = ConnectionMode.Gateway, ConnectionProtocol = Protocol.Https }))
|
||||
{
|
||||
RunDemoAsync(DatabaseName, CollectionName).Wait();
|
||||
}
|
||||
|
@ -63,14 +64,12 @@
|
|||
|
||||
private static async Task RunDemoAsync(string databaseId, string collectionId)
|
||||
{
|
||||
//Get, or Create, the Database
|
||||
Database database = await GetNewDatabaseAsync(databaseId);
|
||||
|
||||
//Get, or Create, the Document Collection
|
||||
DocumentCollection collection = await GetOrCreateCollectionAsync(databaseId, collectionId);
|
||||
|
||||
//Create documents needed for query samples
|
||||
await CreateDocuments(collection.SelfLink);
|
||||
|
||||
Uri collectionUri = UriFactory.CreateDocumentCollectionUri(databaseId, collectionId);
|
||||
|
||||
await CreateDocuments(collectionUri);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// There are three ways of writing queries in the .NET SDK for DocumentDB,
|
||||
|
@ -81,82 +80,82 @@
|
|||
//
|
||||
// There are some occasions when one syntax has advantages over others, but it's your choice which to use when
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Querying for all documents
|
||||
QueryAllDocuments(collection.SelfLink);
|
||||
QueryAllDocuments(collectionUri);
|
||||
|
||||
// Querying for equality using ==
|
||||
QueryWithEquality(collection.SelfLink);
|
||||
QueryWithEquality(collectionUri);
|
||||
|
||||
// Querying for inequality using != and NOT
|
||||
QueryWithInequality(collection.SelfLink);
|
||||
|
||||
QueryWithInequality(collectionUri);
|
||||
|
||||
// Querying using range operators like >, <, >=, <=
|
||||
QueryWithRangeOperatorsOnNumbers(collection.SelfLink);
|
||||
QueryWithRangeOperatorsOnNumbers(collectionUri);
|
||||
|
||||
// Querying using range operators against strings. Needs a different indexing policy or the EnableScanInQuery directive.
|
||||
QueryWithRangeOperatorsOnStrings(collection.SelfLink);
|
||||
QueryWithRangeOperatorsOnStrings(collectionUri);
|
||||
|
||||
// Querying with order by
|
||||
QueryWithOrderBy(collection.SelfLink);
|
||||
QueryWithOrderBy(collectionUri);
|
||||
|
||||
// Work with subdocuments
|
||||
QueryWithSubdocuments(collection.SelfLink);
|
||||
QueryWithSubdocuments(collectionUri);
|
||||
|
||||
// Query with Intra-document Joins
|
||||
QueryWithJoins(collection.SelfLink);
|
||||
QueryWithJoins(collectionUri);
|
||||
|
||||
// Query with string, math and array operators
|
||||
QueryWithStringMathAndArrayOperators(collection.SelfLink);
|
||||
QueryWithStringMathAndArrayOperators(collectionUri);
|
||||
|
||||
// Query with parameterized SQL using SqlQuerySpec
|
||||
QueryWithSqlQuerySpec(collection.SelfLink);
|
||||
|
||||
QueryWithSqlQuerySpec(collectionUri);
|
||||
|
||||
// Query with explict Paging
|
||||
await QueryWithPagingAsync(collection.SelfLink);
|
||||
|
||||
await QueryWithPagingAsync(collectionUri);
|
||||
|
||||
// Query across multiple partitions in parallel
|
||||
await QueryPartitionedCollectionInParallelAsync(collection.SelfLink);
|
||||
await QueryPartitionedCollectionInParallelAsync(collectionUri);
|
||||
|
||||
// Query using order by across multiple partitions
|
||||
await QueryWithOrderByForPartitionedCollectionAsync(collection.SelfLink);
|
||||
|
||||
//Cleanup
|
||||
await client.DeleteDatabaseAsync(database.SelfLink);
|
||||
await QueryWithOrderByForPartitionedCollectionAsync(collectionUri);
|
||||
|
||||
// Cleanup
|
||||
await client.DeleteDatabaseAsync(UriFactory.CreateDatabaseUri(databaseId));
|
||||
}
|
||||
|
||||
private static void QueryAllDocuments(string collectionLink)
|
||||
private static void QueryAllDocuments(Uri collectionUri)
|
||||
{
|
||||
// LINQ Query
|
||||
var families =
|
||||
from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
var families =
|
||||
from f in client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
select f;
|
||||
|
||||
Assert("Expected two families", families.ToList().Count == 2);
|
||||
|
||||
Assert("Expected two families", families.AsEnumerable().Count() == 2);
|
||||
|
||||
// LINQ Lambda
|
||||
families = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions);
|
||||
families = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions);
|
||||
Assert("Expected two families", families.ToList().Count == 2);
|
||||
|
||||
// SQL
|
||||
families = client.CreateDocumentQuery<Family>(collectionLink, "SELECT * FROM Families", DefaultOptions);
|
||||
families = client.CreateDocumentQuery<Family>(collectionUri, "SELECT * FROM Families", DefaultOptions);
|
||||
Assert("Expected two families", families.ToList().Count == 2);
|
||||
}
|
||||
|
||||
private static void QueryWithSqlQuerySpec(string collectionLink)
|
||||
private static void QueryWithSqlQuerySpec(Uri collectionUri)
|
||||
{
|
||||
// Simple query with a single property equality comparison
|
||||
// in SQL with SQL parameterization instead of inlining the
|
||||
// parameter values in the query string
|
||||
// LINQ Query -- Id == "value"
|
||||
var query = client.CreateDocumentQuery<Family>(collectionLink, new SqlQuerySpec()
|
||||
{
|
||||
QueryText = "SELECT * FROM Families f WHERE (f.id = @id)",
|
||||
Parameters = new SqlParameterCollection()
|
||||
var query = client.CreateDocumentQuery<Family>(collectionUri, new SqlQuerySpec()
|
||||
{
|
||||
QueryText = "SELECT * FROM Families f WHERE (f.id = @id)",
|
||||
Parameters = new SqlParameterCollection()
|
||||
{
|
||||
new SqlParameter("@id", "AndersenFamily")
|
||||
}
|
||||
}, DefaultOptions);
|
||||
}, DefaultOptions);
|
||||
|
||||
var families = query.ToList();
|
||||
Assert("Expected only 1 family", families.Count == 1);
|
||||
|
@ -165,7 +164,7 @@
|
|||
// notice here how we are doing an equality comparison on the string value of City
|
||||
|
||||
query = client.CreateDocumentQuery<Family>(
|
||||
collectionLink,
|
||||
collectionUri,
|
||||
new SqlQuerySpec()
|
||||
{
|
||||
QueryText = "SELECT * FROM Families f WHERE f.id = @id AND f.Address.City = @city",
|
||||
|
@ -180,30 +179,30 @@
|
|||
Assert("Expected only 1 family", families.Count == 1);
|
||||
}
|
||||
|
||||
private static void QueryWithEquality(string collectionLink)
|
||||
private static void QueryWithEquality(Uri collectionUri)
|
||||
{
|
||||
// Simple query with a single property equality comparison
|
||||
QueryWithEqualsOnId(collectionLink);
|
||||
QueryWithEqualsOnId(collectionUri);
|
||||
|
||||
// Query using two properties within each document (WHERE Id == "" AND Address.City == "")
|
||||
// Notice here how we are doing an equality comparison on the string value of City
|
||||
QueryWithAndFilter(collectionLink);
|
||||
QueryWithAndFilter(collectionUri);
|
||||
|
||||
//Query using a filter on two properties and include a custom projection
|
||||
//in to a new anonymous type
|
||||
QueryWithAndFilterAndProjection(collectionLink);
|
||||
QueryWithAndFilterAndProjection(collectionUri);
|
||||
}
|
||||
|
||||
private static void QueryWithAndFilterAndProjection(string collectionLink)
|
||||
private static void QueryWithAndFilterAndProjection(Uri collectionUri)
|
||||
{
|
||||
// LINQ Query -- Id == "value" OR City == "value"
|
||||
var query =
|
||||
from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
from f in client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
where f.Id == "AndersenFamily" || f.Address.City == "NY"
|
||||
select new { Name = f.LastName, City = f.Address.City };
|
||||
|
||||
var query2 = client.CreateDocumentQuery<Family>(
|
||||
collectionLink,
|
||||
collectionUri,
|
||||
new FeedOptions { MaxItemCount = 1, EnableCrossPartitionQuery = true })
|
||||
.Where(d => d.LastName == "Andersen")
|
||||
.Select(f => new { Name = f.LastName })
|
||||
|
@ -215,7 +214,7 @@
|
|||
}
|
||||
|
||||
// LINQ Lambda -- Id == "value" OR City == "value"
|
||||
query = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
query = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
.Where(f => f.Id == "AndersenFamily" || f.Address.City == "NY")
|
||||
.Select(f => new { Name = f.LastName, City = f.Address.City });
|
||||
|
||||
|
@ -225,7 +224,7 @@
|
|||
}
|
||||
|
||||
// SQL -- Id == "value" OR City == "value"
|
||||
var q = client.CreateDocumentQuery(collectionLink,
|
||||
var q = client.CreateDocumentQuery(collectionUri,
|
||||
"SELECT f.LastName AS Name, f.Address.City AS City " +
|
||||
"FROM Families f " +
|
||||
"WHERE f.id='AndersenFamily' OR f.Address.City='NY'", DefaultOptions);
|
||||
|
@ -236,81 +235,83 @@
|
|||
}
|
||||
}
|
||||
|
||||
private static void QueryWithAndFilter(string collectionLink)
|
||||
private static void QueryWithAndFilter(Uri collectionUri)
|
||||
{
|
||||
// LINQ Query
|
||||
var families = from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
where f.Id == "AndersenFamily" && f.Address.City == "Seattle"
|
||||
select f;
|
||||
var families = from f in client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
where f.Id == "AndersenFamily" && f.Address.City == "Seattle"
|
||||
select f;
|
||||
|
||||
Assert("Expected only 1 family", families.ToList().Count == 1);
|
||||
|
||||
// LINQ Lambda -- Id == "value" AND City == "value"
|
||||
families = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
families = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
.Where(f => f.Id == "AndersenFamily" && f.Address.City == "Seattle");
|
||||
|
||||
Assert("Expected only 1 family", families.ToList().Count == 1);
|
||||
|
||||
// SQL -- Id == "value" AND City == "value"
|
||||
families = client.CreateDocumentQuery<Family>(
|
||||
collectionLink,
|
||||
collectionUri,
|
||||
"SELECT * FROM Families f WHERE f.id='AndersenFamily' AND f.Address.City='Seattle'",
|
||||
DefaultOptions);
|
||||
|
||||
Assert("Expected only 1 family", families.ToList().Count == 1);
|
||||
}
|
||||
|
||||
private static void QueryWithEqualsOnId(string collectionLink)
|
||||
private static void QueryWithEqualsOnId(Uri collectionUri)
|
||||
{
|
||||
// LINQ Query -- Id == "value"
|
||||
var families =
|
||||
from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
from f in client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
where f.Id == "AndersenFamily"
|
||||
select f;
|
||||
|
||||
Assert("Expected only 1 family", families.ToList().Count == 1);
|
||||
|
||||
// LINQ Lambda -- Id == "value"
|
||||
families = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions).Where(f => f.Id == "AndersenFamily");
|
||||
families = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions).Where(f => f.Id == "AndersenFamily");
|
||||
Assert("Expected only 1 family", families.ToList().Count == 1);
|
||||
|
||||
// SQL -- Id == "value"
|
||||
families = client.CreateDocumentQuery<Family>(
|
||||
collectionLink,
|
||||
"SELECT * FROM Families f WHERE f.id='AndersenFamily'",
|
||||
collectionUri,
|
||||
"SELECT * FROM Families f WHERE f.id='AndersenFamily'",
|
||||
DefaultOptions);
|
||||
Assert("Expected only 1 family", families.ToList().Count == 1);
|
||||
}
|
||||
|
||||
private static void QueryWithInequality(string collectionLink)
|
||||
private static void QueryWithInequality(Uri collectionUri)
|
||||
{
|
||||
// Simple query with a single property inequality comparison
|
||||
// LINQ Query
|
||||
var query = from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
where f.Id != "AndersenFamily"
|
||||
select f;
|
||||
var query = from f in client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
where f.Id != "AndersenFamily"
|
||||
select f;
|
||||
|
||||
var families = query.ToList();
|
||||
Assert("Expected only 1 family", families.Count == 1);
|
||||
|
||||
|
||||
// LINQ Lambda
|
||||
query = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
query = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
.Where(f => f.Id != "AndersenFamily");
|
||||
|
||||
families = query.ToList();
|
||||
Assert("Expected only 1 family", families.Count == 1);
|
||||
|
||||
|
||||
|
||||
// SQL - in SQL you can use <> interchangably with != for "not equals"
|
||||
query = client.CreateDocumentQuery<Family>(
|
||||
collectionLink,
|
||||
collectionUri,
|
||||
"SELECT * FROM Families f WHERE f.id <> 'AndersenFamily'",
|
||||
DefaultOptions);
|
||||
|
||||
families = query.ToList();
|
||||
Assert("Expected only 1 family", families.ToList().Count == 1);
|
||||
|
||||
|
||||
//combine equality and inequality
|
||||
query =
|
||||
from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
query =
|
||||
from f in client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
where f.Id == "Wakefield" && f.Address.City != "NY"
|
||||
select f;
|
||||
|
||||
|
@ -318,7 +319,7 @@
|
|||
Assert("Expected no results", families.Count == 0);
|
||||
|
||||
query = client.CreateDocumentQuery<Family>(
|
||||
collectionLink,
|
||||
collectionUri,
|
||||
"SELECT * FROM Families f WHERE f.id = 'AndersenFamily' AND f.Address.City != 'NY'",
|
||||
DefaultOptions);
|
||||
|
||||
|
@ -326,23 +327,23 @@
|
|||
Assert("Expected only 1 family", families.Count == 1);
|
||||
}
|
||||
|
||||
private static void QueryWithRangeOperatorsOnNumbers(string collectionLink)
|
||||
private static void QueryWithRangeOperatorsOnNumbers(Uri collectionUri)
|
||||
{
|
||||
// LINQ Query
|
||||
var families = from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
var families = from f in client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
where f.Children[0].Grade > 5
|
||||
select f;
|
||||
|
||||
Assert("Expected only 1 family", families.ToList().Count == 1);
|
||||
|
||||
// LINQ Lambda
|
||||
families = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
families = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
.Where(f => f.Children[0].Grade > 5);
|
||||
|
||||
Assert("Expected only 1 family", families.ToList().Count == 1);
|
||||
|
||||
// SQL
|
||||
families = client.CreateDocumentQuery<Family>(collectionLink,
|
||||
families = client.CreateDocumentQuery<Family>(collectionUri,
|
||||
"SELECT * FROM Families f WHERE f.Children[0].Grade > 5",
|
||||
DefaultOptions);
|
||||
|
||||
|
@ -350,31 +351,31 @@
|
|||
}
|
||||
|
||||
|
||||
private static void QueryWithOrderBy(string collectionLink)
|
||||
private static void QueryWithOrderBy(Uri collectionUri)
|
||||
{
|
||||
// Order by with numbers. Works with default IndexingPolicy
|
||||
QueryWithOrderByNumbers(collectionLink);
|
||||
QueryWithOrderByNumbers(collectionUri);
|
||||
|
||||
// Order by with strings. Needs custom indexing policy. See GetOrCreateCollectionAsync
|
||||
QueryWithOrderByStrings(collectionLink);
|
||||
QueryWithOrderByStrings(collectionUri);
|
||||
}
|
||||
|
||||
private static void QueryWithRangeOperatorsOnStrings(string collectionLink)
|
||||
private static void QueryWithRangeOperatorsOnStrings(Uri collectionUri)
|
||||
{
|
||||
// SQL Query (can't do this in LINQ)
|
||||
var families = client.CreateDocumentQuery<Family>(
|
||||
collectionLink,
|
||||
"SELECT * FROM Families f WHERE f.Address.State > 'NY'",
|
||||
collectionUri,
|
||||
"SELECT * FROM Families f WHERE f.Address.State > 'NY'",
|
||||
new FeedOptions { EnableScanInQuery = true, EnableCrossPartitionQuery = true });
|
||||
|
||||
|
||||
Assert("Expected only 1 family", families.ToList().Count == 1);
|
||||
}
|
||||
|
||||
private static void QueryWithOrderByNumbers(string collectionLink)
|
||||
private static void QueryWithOrderByNumbers(Uri collectionUri)
|
||||
{
|
||||
// LINQ Query
|
||||
var familiesLinqQuery =
|
||||
from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
var familiesLinqQuery =
|
||||
from f in client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
where f.LastName == "Andersen"
|
||||
orderby f.Children[0].Grade
|
||||
select f;
|
||||
|
@ -382,7 +383,7 @@
|
|||
Assert("Expected 1 families", familiesLinqQuery.ToList().Count == 1);
|
||||
|
||||
// LINQ Lambda
|
||||
familiesLinqQuery = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
familiesLinqQuery = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
.Where(f => f.LastName == "Andersen")
|
||||
.OrderBy(f => f.Children[0].Grade);
|
||||
|
||||
|
@ -390,25 +391,25 @@
|
|||
|
||||
// SQL
|
||||
var familiesSqlQuery = client.CreateDocumentQuery<Family>(
|
||||
collectionLink,
|
||||
collectionUri,
|
||||
"SELECT * FROM Families f WHERE f.LastName = 'Andersen' ORDER BY f.Children[0].Grade",
|
||||
DefaultOptions);
|
||||
|
||||
Assert("Expected 1 families", familiesSqlQuery.ToList().Count == 1);
|
||||
}
|
||||
|
||||
private static void QueryWithOrderByStrings(string collectionLink)
|
||||
private static void QueryWithOrderByStrings(Uri collectionUri)
|
||||
{
|
||||
// LINQ Query
|
||||
var familiesLinqQuery = from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
where f.LastName == "Andersen"
|
||||
orderby f.Address.State descending
|
||||
select f;
|
||||
var familiesLinqQuery = from f in client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
where f.LastName == "Andersen"
|
||||
orderby f.Address.State descending
|
||||
select f;
|
||||
|
||||
Assert("Expected only 1 family", familiesLinqQuery.ToList().Count == 1);
|
||||
|
||||
// LINQ Lambda
|
||||
familiesLinqQuery = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
familiesLinqQuery = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
.Where(f => f.LastName == "Andersen")
|
||||
.OrderByDescending(f => f.Address.State);
|
||||
|
||||
|
@ -416,14 +417,14 @@
|
|||
|
||||
// SQL
|
||||
var familiesSqlQuery = client.CreateDocumentQuery<Family>(
|
||||
collectionLink,
|
||||
collectionUri,
|
||||
"SELECT * FROM Families f WHERE f.LastName = 'Andersen' ORDER BY f.Address.State DESC",
|
||||
DefaultOptions);
|
||||
|
||||
Assert("Expected only 1 family", familiesSqlQuery.ToList().Count == 1);
|
||||
}
|
||||
|
||||
private static void QueryWithSubdocuments(string collectionLink)
|
||||
private static void QueryWithSubdocuments(Uri collectionUri)
|
||||
{
|
||||
// DocumentDB supports the selection of sub-documents on the server, there
|
||||
// is no need to send down the full family record if all you want to display
|
||||
|
@ -431,8 +432,8 @@
|
|||
|
||||
// SQL
|
||||
var childrenSqlQuery = client.CreateDocumentQuery<Child>(
|
||||
collectionLink,
|
||||
"SELECT c FROM c IN f.Children",
|
||||
collectionUri,
|
||||
"SELECT c FROM c IN f.Children",
|
||||
DefaultOptions).ToList();
|
||||
|
||||
foreach (var child in childrenSqlQuery)
|
||||
|
@ -441,35 +442,35 @@
|
|||
}
|
||||
|
||||
// LINQ Query
|
||||
var childrenLinqQuery = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
.SelectMany(family => family.Children
|
||||
.Select(c => c));
|
||||
var childrenLinqQuery = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
.SelectMany(family => family.Children
|
||||
.Select(c => c));
|
||||
|
||||
foreach (var child in childrenLinqQuery)
|
||||
{
|
||||
Console.WriteLine(JsonConvert.SerializeObject(child));
|
||||
}
|
||||
foreach (var child in childrenLinqQuery)
|
||||
{
|
||||
Console.WriteLine(JsonConvert.SerializeObject(child));
|
||||
}
|
||||
}
|
||||
|
||||
private static void QueryWithJoins(string collectionLink)
|
||||
private static void QueryWithJoins(Uri collectionUri)
|
||||
{
|
||||
// DocumentDB supports the notion of a Intradocument Join, or a self-join
|
||||
// which will effectively flatten the hierarchy of a document, just like doing
|
||||
// a self JOIN on a SQL table
|
||||
|
||||
|
||||
// Below are three queries involving JOIN, shown in SQL and in LINQ, each produces the exact same result set
|
||||
QueryWithSingleJoin(collectionLink);
|
||||
QueryWithSingleJoin(collectionUri);
|
||||
|
||||
//now lets add a second level by joining the pets on to children which is joined to family
|
||||
QueryWithTwoJoins(collectionLink);
|
||||
QueryWithTwoJoins(collectionUri);
|
||||
|
||||
// Now let's add a filter to our JOIN query
|
||||
QueryWithTwoJoinsAndFilter(collectionLink);
|
||||
QueryWithTwoJoinsAndFilter(collectionUri);
|
||||
}
|
||||
|
||||
private static void QueryWithTwoJoinsAndFilter(string collectionLink)
|
||||
private static void QueryWithTwoJoinsAndFilter(Uri collectionUri)
|
||||
{
|
||||
var query = client.CreateDocumentQuery<dynamic>(collectionLink,
|
||||
var query = client.CreateDocumentQuery<dynamic>(collectionUri,
|
||||
"SELECT f.id as family, c.FirstName AS child, p.GivenName AS pet " +
|
||||
"FROM Families f " +
|
||||
"JOIN c IN f.Children " +
|
||||
|
@ -484,11 +485,11 @@
|
|||
}
|
||||
|
||||
// LINQ
|
||||
var familiesChildrenAndPets = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
var familiesChildrenAndPets = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
.SelectMany(family => family.Children
|
||||
.SelectMany(child => child.Pets
|
||||
.Where(pet => pet.GivenName == "Fluffy")
|
||||
.Select(pet => new
|
||||
.Select(pet => new
|
||||
{
|
||||
family = family.Id,
|
||||
child = child.FirstName,
|
||||
|
@ -502,11 +503,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
private static void QueryWithTwoJoins(string collectionLink)
|
||||
private static void QueryWithTwoJoins(Uri collectionUri)
|
||||
{
|
||||
// SQL
|
||||
var familiesChildrenAndPets = client.CreateDocumentQuery<dynamic>(
|
||||
collectionLink,
|
||||
collectionUri,
|
||||
"SELECT f.id as family, c.FirstName AS child, p.GivenName AS pet " +
|
||||
"FROM Families f " +
|
||||
"JOIN c IN f.Children " +
|
||||
|
@ -519,7 +520,7 @@
|
|||
}
|
||||
|
||||
// LINQ
|
||||
familiesChildrenAndPets = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
familiesChildrenAndPets = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
.SelectMany(family => family.Children
|
||||
.SelectMany(child => child.Pets
|
||||
.Select(pet => new
|
||||
|
@ -529,18 +530,18 @@
|
|||
pet = pet.GivenName
|
||||
}
|
||||
)));
|
||||
|
||||
|
||||
foreach (var item in familiesChildrenAndPets)
|
||||
{
|
||||
Console.WriteLine(item);
|
||||
}
|
||||
}
|
||||
|
||||
private static void QueryWithSingleJoin(string collectionLink)
|
||||
private static void QueryWithSingleJoin(Uri collectionUri)
|
||||
{
|
||||
|
||||
// SQL
|
||||
var query = client.CreateDocumentQuery(collectionLink,
|
||||
var query = client.CreateDocumentQuery(collectionUri,
|
||||
"SELECT f.id " +
|
||||
"FROM Families f " +
|
||||
"JOIN c IN f.Children", DefaultOptions);
|
||||
|
@ -551,7 +552,7 @@
|
|||
}
|
||||
|
||||
// LINQ
|
||||
var familiesAndChildren = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
var familiesAndChildren = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
.SelectMany(family => family.Children
|
||||
.Select(c => family.Id));
|
||||
|
||||
|
@ -561,52 +562,52 @@
|
|||
}
|
||||
}
|
||||
|
||||
private static void QueryWithStringMathAndArrayOperators(string collectionLink)
|
||||
private static void QueryWithStringMathAndArrayOperators(Uri collectionUri)
|
||||
{
|
||||
// Find all families where the lastName starts with "An" -> should return the Andersens
|
||||
IQueryable<Family> results = client.CreateDocumentQuery<Family>(
|
||||
collectionLink,
|
||||
"SELECT * FROM family WHERE STARTSWITH(family.LastName, 'An')",
|
||||
collectionUri,
|
||||
"SELECT * FROM family WHERE STARTSWITH(family.LastName, 'An')",
|
||||
DefaultOptions);
|
||||
Assert("Expected only 1 family", results.AsEnumerable().Count() == 1);
|
||||
|
||||
// Same query in LINQ. You can also use other operators like string.Contains(), string.EndsWith(), string.Trim(), etc.
|
||||
results = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
results = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
.Where(family => family.LastName.StartsWith("An"));
|
||||
Assert("Expected only 1 family", results.AsEnumerable().Count() == 1);
|
||||
|
||||
// Round down numbers using FLOOR
|
||||
IQueryable<int> numericResults = client.CreateDocumentQuery<int>(
|
||||
collectionLink,
|
||||
collectionUri,
|
||||
"SELECT VALUE FLOOR(family.Children[0].Grade) FROM family",
|
||||
DefaultOptions);
|
||||
Assert("Expected grades [5, 2]", numericResults.AsEnumerable().SequenceEqual(new [] { 5, 8 }));
|
||||
Assert("Expected grades [5, 2]", numericResults.AsEnumerable().SequenceEqual(new[] { 5, 8 }));
|
||||
|
||||
// Same query in LINQ. You can also use other Math operators
|
||||
numericResults = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
numericResults = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
.Select(family => (int)Math.Round((double)family.Children[0].Grade));
|
||||
Assert("Expected grades [5, 2]", numericResults.AsEnumerable().SequenceEqual(new[] { 5, 8 }));
|
||||
|
||||
// Get number of children using ARRAY_LENGTH
|
||||
numericResults = client.CreateDocumentQuery<int>(
|
||||
collectionLink,
|
||||
collectionUri,
|
||||
"SELECT VALUE ARRAY_LENGTH(family.Children) FROM family",
|
||||
DefaultOptions);
|
||||
Assert("Expected children count [1, 2]", numericResults.AsEnumerable().SequenceEqual(new[] { 1, 2 }));
|
||||
|
||||
// Same query in LINQ
|
||||
numericResults = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
|
||||
numericResults = client.CreateDocumentQuery<Family>(collectionUri, DefaultOptions)
|
||||
.Select(family => family.Children.Count());
|
||||
Assert("Expected children count [1, 2]", numericResults.AsEnumerable().SequenceEqual(new[] { 1, 2 }));
|
||||
}
|
||||
|
||||
private static async Task QueryWithPagingAsync(string collectionLink)
|
||||
|
||||
private static async Task QueryWithPagingAsync(Uri collectionUri)
|
||||
{
|
||||
// The .NET client automatically iterates through all the pages of query results
|
||||
// Developers can explicitly control paging by creating an IDocumentQueryable
|
||||
// using the IQueryable object, then by reading the ResponseContinuationToken values
|
||||
// and passing them back as RequestContinuationToken in FeedOptions.
|
||||
|
||||
|
||||
List<Family> families = new List<Family>();
|
||||
|
||||
// tell server we only want 1 record
|
||||
|
@ -615,7 +616,7 @@
|
|||
// using AsDocumentQuery you get access to whether or not the query HasMoreResults
|
||||
// If it does, just call ExecuteNextAsync until there are no more results
|
||||
// No need to supply a continuation token here as the server keeps track of progress
|
||||
var query = client.CreateDocumentQuery<Family>(collectionLink, options).AsDocumentQuery();
|
||||
var query = client.CreateDocumentQuery<Family>(collectionUri, options).AsDocumentQuery();
|
||||
while (query.HasMoreResults)
|
||||
{
|
||||
foreach (Family family in await query.ExecuteNextAsync())
|
||||
|
@ -631,7 +632,7 @@
|
|||
// and use it on subsequent queries
|
||||
|
||||
query = client.CreateDocumentQuery<Family>(
|
||||
collectionLink,
|
||||
collectionUri,
|
||||
new FeedOptions { MaxItemCount = 1, EnableCrossPartitionQuery = true }).AsDocumentQuery();
|
||||
|
||||
var feedResponse = await query.ExecuteNextAsync<Family>();
|
||||
|
@ -639,13 +640,13 @@
|
|||
|
||||
foreach (var f in feedResponse.AsEnumerable().OrderBy(f => f.Id))
|
||||
{
|
||||
if (f.Id != "AndersenFamily") throw new ApplicationException("Should only be the first family");
|
||||
}
|
||||
if (f.Id != "AndersenFamily") throw new ApplicationException("Should only be the first family");
|
||||
}
|
||||
|
||||
// Now the second time around use the contiuation token you got
|
||||
// and start the process from that point
|
||||
query = client.CreateDocumentQuery<Family>(
|
||||
collectionLink,
|
||||
collectionUri,
|
||||
new FeedOptions
|
||||
{
|
||||
MaxItemCount = 1,
|
||||
|
@ -654,14 +655,14 @@
|
|||
}).AsDocumentQuery();
|
||||
|
||||
feedResponse = await query.ExecuteNextAsync<Family>();
|
||||
|
||||
|
||||
foreach (var f in feedResponse.AsEnumerable().OrderBy(f => f.Id))
|
||||
{
|
||||
if (f.Id != "WakefieldFamily") throw new ApplicationException("Should only be the second family");
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task QueryPartitionedCollectionInParallelAsync(string collectionLink)
|
||||
|
||||
private static async Task QueryPartitionedCollectionInParallelAsync(Uri collectionUri)
|
||||
{
|
||||
// The .NET client automatically iterates through all the pages of query results
|
||||
// Developers can explicitly control paging by creating an IDocumentQueryable
|
||||
|
@ -679,7 +680,7 @@
|
|||
EnableCrossPartitionQuery = true
|
||||
};
|
||||
|
||||
var query = client.CreateDocumentQuery<Family>(collectionLink, queryText, options).AsDocumentQuery();
|
||||
var query = client.CreateDocumentQuery<Family>(collectionUri, queryText, options).AsDocumentQuery();
|
||||
while (query.HasMoreResults)
|
||||
{
|
||||
foreach (Family family in await query.ExecuteNextAsync().ConfigureAwait(false))
|
||||
|
@ -691,7 +692,7 @@
|
|||
Assert("Parallel Query expected two families", familiesSerial.ToList().Count == 2);
|
||||
|
||||
// 1 maximum parallel tasks, 1 dedicated asynchrousnous task to continuously make REST calls
|
||||
List<Family> familiesParallel1= new List<Family>();
|
||||
List<Family> familiesParallel1 = new List<Family>();
|
||||
options = new FeedOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = 1,
|
||||
|
@ -699,7 +700,7 @@
|
|||
EnableCrossPartitionQuery = true
|
||||
};
|
||||
|
||||
query = client.CreateDocumentQuery<Family>(collectionLink, options).AsDocumentQuery();
|
||||
query = client.CreateDocumentQuery<Family>(collectionUri, options).AsDocumentQuery();
|
||||
while (query.HasMoreResults)
|
||||
{
|
||||
foreach (Family family in await query.ExecuteNextAsync())
|
||||
|
@ -721,7 +722,7 @@
|
|||
EnableCrossPartitionQuery = true
|
||||
};
|
||||
|
||||
query = client.CreateDocumentQuery<Family>(collectionLink, options).AsDocumentQuery();
|
||||
query = client.CreateDocumentQuery<Family>(collectionUri, options).AsDocumentQuery();
|
||||
while (query.HasMoreResults)
|
||||
{
|
||||
foreach (Family family in await query.ExecuteNextAsync())
|
||||
|
@ -733,8 +734,8 @@
|
|||
Assert("Parallel Query expected two families", familiesParallel10.ToList().Count == 2);
|
||||
AssertSequenceEqual("Parallel query returns result out of order compared to serial execution", familiesSerial, familiesParallel10);
|
||||
}
|
||||
|
||||
private static async Task QueryWithOrderByForPartitionedCollectionAsync(string collectionLink)
|
||||
|
||||
private static async Task QueryWithOrderByForPartitionedCollectionAsync(Uri collectionUri)
|
||||
{
|
||||
// The .NET client automatically iterates through all the pages of query results
|
||||
// Developers can explicitly control paging by creating an IDocumentQueryable
|
||||
|
@ -752,7 +753,7 @@
|
|||
EnableCrossPartitionQuery = true
|
||||
};
|
||||
|
||||
var query = client.CreateDocumentQuery<Family>(collectionLink, queryText, options).AsDocumentQuery();
|
||||
var query = client.CreateDocumentQuery<Family>(collectionUri, queryText, options).AsDocumentQuery();
|
||||
while (query.HasMoreResults)
|
||||
{
|
||||
foreach (Family family in await query.ExecuteNextAsync())
|
||||
|
@ -775,7 +776,7 @@
|
|||
// using AsDocumentQuery you get access to whether or not the query HasMoreResults
|
||||
// If it does, just call ExecuteNextAsync until there are no more results
|
||||
// No need to supply a continuation token here as the server keeps track of progress
|
||||
query = client.CreateDocumentQuery<Family>(collectionLink, queryText, options).AsDocumentQuery();
|
||||
query = client.CreateDocumentQuery<Family>(collectionUri, queryText, options).AsDocumentQuery();
|
||||
while (query.HasMoreResults)
|
||||
{
|
||||
foreach (Family family in await query.ExecuteNextAsync())
|
||||
|
@ -796,7 +797,7 @@
|
|||
EnableCrossPartitionQuery = true
|
||||
};
|
||||
|
||||
query = client.CreateDocumentQuery<Family>(collectionLink, queryText, options).AsDocumentQuery();
|
||||
query = client.CreateDocumentQuery<Family>(collectionUri, queryText, options).AsDocumentQuery();
|
||||
while (query.HasMoreResults)
|
||||
{
|
||||
foreach (Family family in await query.ExecuteNextAsync())
|
||||
|
@ -812,15 +813,15 @@
|
|||
/// <summary>
|
||||
/// Creates the documents used in this Sample
|
||||
/// </summary>
|
||||
/// <param name="collectionLink">The selfLink property for the DocumentCollection where documents will be created.</param>
|
||||
/// <param name="collectionUri">The selfLink property for the DocumentCollection where documents will be created.</param>
|
||||
/// <returns>None</returns>
|
||||
private static async Task CreateDocuments(string collectionLink)
|
||||
private static async Task CreateDocuments(Uri collectionUri)
|
||||
{
|
||||
Family AndersonFamily = new Family
|
||||
{
|
||||
Id = "AndersenFamily",
|
||||
LastName = "Andersen",
|
||||
Parents = new Parent[] {
|
||||
Parents = new Parent[] {
|
||||
new Parent { FirstName = "Thomas" },
|
||||
new Parent { FirstName = "Mary Kay"}
|
||||
},
|
||||
|
@ -839,13 +840,13 @@
|
|||
IsRegistered = true
|
||||
};
|
||||
|
||||
await client.CreateDocumentAsync(collectionLink, AndersonFamily);
|
||||
await client.CreateDocumentAsync(collectionUri, AndersonFamily);
|
||||
|
||||
Family WakefieldFamily = new Family
|
||||
{
|
||||
Id = "WakefieldFamily",
|
||||
LastName = "Wakefield",
|
||||
Parents = new [] {
|
||||
Parents = new[] {
|
||||
new Parent { FamilyName= "Wakefield", FirstName= "Robin" },
|
||||
new Parent { FamilyName= "Miller", FirstName= "Ben" }
|
||||
},
|
||||
|
@ -863,7 +864,6 @@
|
|||
},
|
||||
new Child
|
||||
{
|
||||
FamilyName= "Miller",
|
||||
FirstName= "Lisa",
|
||||
Gender= "female",
|
||||
Grade= 1
|
||||
|
@ -873,7 +873,7 @@
|
|||
IsRegistered = false
|
||||
};
|
||||
|
||||
await client.CreateDocumentAsync(collectionLink, WakefieldFamily);
|
||||
await client.CreateDocumentAsync(collectionUri, WakefieldFamily);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -896,15 +896,15 @@
|
|||
collectionDefinition.PartitionKey.Paths.Add("/LastName");
|
||||
|
||||
collection = await DocumentClientHelper.CreateDocumentCollectionWithRetriesAsync(
|
||||
client,
|
||||
databaseId,
|
||||
client,
|
||||
databaseId,
|
||||
collectionDefinition,
|
||||
400);
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a Database for this id. Delete if it already exists.
|
||||
/// </summary>
|
||||
|
@ -952,10 +952,10 @@
|
|||
throw new ApplicationException(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void AssertSequenceEqual(string message, List<Family> list1, List<Family> list2)
|
||||
{
|
||||
if(!string.Join(",", list1.Select(family => family.Id).ToArray()).Equals(
|
||||
if (!string.Join(",", list1.Select(family => family.Id).ToArray()).Equals(
|
||||
string.Join(",", list1.Select(family => family.Id).ToArray())))
|
||||
{
|
||||
throw new ApplicationException(message);
|
||||
|
@ -991,7 +991,7 @@
|
|||
|
||||
internal sealed class Family
|
||||
{
|
||||
[JsonProperty(PropertyName="id")]
|
||||
[JsonProperty(PropertyName = "id")]
|
||||
public string Id { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public Parent[] Parents { get; set; }
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
@ -44,8 +45,8 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.9.2\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
|
@ -88,7 +89,9 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.6.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.9.2" targetFramework="net451" />
|
||||
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
|
||||
</packages>
|
|
@ -44,8 +44,8 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.9.2\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
|
@ -401,7 +401,9 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.6.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.9.2" targetFramework="net451" />
|
||||
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
|
||||
</packages>
|
|
@ -19,6 +19,11 @@
|
|||
|
||||
[JsonProperty(PropertyName="ponumber")]
|
||||
public string PurchaseOrderNumber { get; set; }
|
||||
|
||||
// used to set expiration policy
|
||||
[JsonProperty(PropertyName = "ttl", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public int? TimeToLive { get; set; }
|
||||
|
||||
public DateTime OrderDate { get; set; }
|
||||
public DateTime ShippedDate { get; set; }
|
||||
public string AccountNumber { get; set; }
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.9.2\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
|
@ -841,7 +841,9 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.6.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.9.2" targetFramework="net451" />
|
||||
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
|
||||
</packages>
|
|
@ -44,8 +44,8 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.9.2\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
|
@ -89,7 +89,9 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.9.2\build\Microsoft.Azure.DocumentDB.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.6.1" targetFramework="net451" />
|
||||
<package id="Microsoft.Azure.DocumentDB" version="1.9.2" targetFramework="net451" />
|
||||
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
|
||||
</packages>
|
|
@ -1,5 +1,5 @@
|
|||
<appSettings>
|
||||
<add key="EndPointUrl" value="FILLME"/>
|
||||
<add key="EndPointUrl" value="https://FILLME.documents.azure.com"/>
|
||||
<add key="AuthorizationKey" value="FILLME"/>
|
||||
<add key="DatabaseId" value="SampleDatabase"/>
|
||||
<add key="CollectionId" value="SampleCollection"/>
|
||||
|
|
Загрузка…
Ссылка в новой задаче