Session: Delete Incremental Time Series
Delete a range of incremental time series entries using IncrementalTimeSeriesFor.Delete
.
-
You can delete a single entry or a range of entries.
-
In this page:
IncrementalTimeSeriesFor.Delete
IncrementalTimeSeriesFor.Delete
is used for the removal of incremental time series and
their entries.
- There is no need to explicitly delete an incremental time series; the series is deleted when all its entries are deleted.
- Attempting to delete nonexistent entries results in a no-op, generating no exception.
Syntax
-
There are two
IncrementalTimeSeriesFor.Delete
methods:- Delete a range of time series entries
-or-
if values are omitted, delete the entire series.
// Delete incremental time series values range from .. to, // or, if values are omitted, delete the whole series. void Delete(DateTime? from = null, DateTime? to = null);
- Delete a single time series entry.
// Delete the entry value at the specified time stamp void Delete(DateTime at);
- Delete a range of time series entries
-
Parameters
Parameters Type Description from
(optional)DateTime?
Delete the range of entries starting at this timestamp. to
(optional)DateTime?
Delete the range of entries ending at this timestamp. at
DateTime
Timestamp of the entry to be deleted. -
Return Value
No return value. -
Exceptions
DocumentDoesNotExistException
is thrown If the document doesn't exist.- Attempting to delete nonexistent entries results in a no-op and does not generate an exception.
Usage Flow
- Open a session
-
Create an instance of
IncrementalTimeSeriesFor
and pass it:- An explicit document ID,
-or-
An entity tracked by the session, e.g. a document object returned from session.Query or from session.Load. - The time series name.
The name must begin with "INC:" (can be upper or lower case) to identify the time series as incremental.
- An explicit document ID,
- Call
IncrementalTimeSeriesFor.Delete
. - Call
session.SaveChanges
for the action to take effect on the server.
Code Samples
-
Delete a single entry:
// Delete a single entry using (var session = store.OpenSession()) { session.IncrementalTimeSeriesFor<Downloads>("companies/webstore") .Delete(baseline.AddMinutes(1)); session.SaveChanges(); }
-
Delete a range of entries:
// Delete a range of entries from the time series using (var session = store.OpenSession()) { session.IncrementalTimeSeriesFor("companies/webstore", "INC:Downloads") .Delete(baseline.AddDays(0), baseline.AddDays(9)); session.SaveChanges(); }