Include Time Series with Query
-
When querying via
session.Query
for documents that contain time series,
you can request to include their time series data in the server response. -
The included time series data is stored within the session
and can be provided instantly when requested without any additional server calls. -
In this page:
Include time series when making a query
In this example, we retrieve a document using session.Query
and include entries from the document's "HeartRates" time series.
using (var session = store.OpenSession())
{
// Query for a document and include a whole time-series
User user = session.Query<User>()
.Where(u => u.Name == "John")
.Include(includeBuilder => includeBuilder.IncludeTimeSeries("HeartRates"))
.FirstOrDefault();
// The following call to 'Get' will Not trigger a server request,
// the entries will be retrieved from the session's cache.
IEnumerable<TimeSeriesEntry> entries = session.TimeSeriesFor(user, "HeartRates")
.Get();
}
Syntax
Include
builder methods:
TBuilder IncludeTimeSeries(string name, DateTime? from = null, DateTime? to = null);
Parameter | Type | Description |
---|---|---|
name | string |
Time series Name. |
from | DateTime? |
Time series range start (inclusive). Default: DateTime.MinValue . |
to | DateTime? |
Time series range end (inclusive). Default: DateTime.MaxValue . |