Skip to content

Commit b349486

Browse files
authored
Merge pull request Azure#325 from heyyjudes/master
Adding if modified since / start time sample code
2 parents f61755e + 4d93e95 commit b349486

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

samples/code-samples/ChangeFeed/ChangeFeed.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
<WarningLevel>4</WarningLevel>
3636
</PropertyGroup>
3737
<ItemGroup>
38-
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.13.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
39-
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.13.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
38+
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.17.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
39+
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.17.0\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
40+
<Private>True</Private>
4041
</Reference>
4142
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
4243
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
@@ -71,12 +72,12 @@
7172
</ProjectReference>
7273
</ItemGroup>
7374
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
74-
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.13.1\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.13.1\build\Microsoft.Azure.DocumentDB.targets')" />
75+
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.17.0\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.17.0\build\Microsoft.Azure.DocumentDB.targets')" />
7576
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
7677
<PropertyGroup>
7778
<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>
7879
</PropertyGroup>
79-
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.13.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.13.1\build\Microsoft.Azure.DocumentDB.targets'))" />
80+
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.17.0\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.17.0\build\Microsoft.Azure.DocumentDB.targets'))" />
8081
</Target>
8182
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
8283
Other similar extension points exist, see Microsoft.Common.targets.

samples/code-samples/ChangeFeed/Program.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ await client.CreateDocumentCollectionIfNotExistsAsync(
6969

7070
Console.WriteLine("Inserting 100 documents");
7171
List<Task> insertTasks = new List<Task>();
72+
/*
7273
for (int i = 0; i < 100; i++)
7374
{
7475
insertTasks.Add(client.CreateDocumentAsync(
@@ -77,7 +78,7 @@ await client.CreateDocumentCollectionIfNotExistsAsync(
7778
}
7879
7980
await Task.WhenAll(insertTasks);
80-
81+
*/
8182
// Returns all documents in the collection.
8283
Console.WriteLine("Reading all changes from the beginning");
8384
Dictionary<string, string> checkpoints = await GetChanges(client, collectionUri, new Dictionary<string, string>());
@@ -136,7 +137,9 @@ private static async Task<Dictionary<string, string>> GetChanges(
136137
PartitionKeyRangeId = pkRange.Id,
137138
StartFromBeginning = true,
138139
RequestContinuation = continuation,
139-
MaxItemCount = -1
140+
MaxItemCount = -1,
141+
// Set reading time: only show change feed results modified since StartTime
142+
StartTime = DateTime.Now - TimeSpan.FromSeconds(30)
140143
});
141144

142145
while (query.HasMoreResults)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Azure.DocumentDB" version="1.13.1" targetFramework="net452" />
3+
<package id="Microsoft.Azure.DocumentDB" version="1.17.0" targetFramework="net452" />
44
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net452" />
55
</packages>

0 commit comments

Comments
 (0)