I am querying built-in TimeoutData entity in RavenDB using Raven.Client.Lightweight 2.5 library to get specific timeout document. It is possible that TimeoutData does not exist in the database because no document is stored there yet. In that case NotSupportedException is thrown when you try to query it.
Currently I have created workaround for this situation:
try
{
timeoutData = _session.Query<TimeoutData>().FirstOrDefault(t => t.Headers.ContainsValue(someValue));
}
catch (NotSupportedException)
{
return null;
}
Is it possible to verify if TimeoutData exist without using try-catch? I have also tried the following code but it returns false when documents exist in TimeoutData entity:
if (!_session.Query<TimeoutData>().Any())
{
}
NotSupportedException
will only be thrown if we can't actually process the query. Are you interested in a specified document, or in whatever anything exists there? – Ranunculusif (!_session.Query<TimeoutData>().Any())
This should give you that informtion – Ranunculus_session.Query<TimeoutData>().Any()
started to work. This post helped me: #3636454. And also TimeoutData is NServiceBus entity for storing deferred messages. – Peking