Reputation: 1305
I want to reuse the following code:
readonly Func<QueryContainerDescriptor<OemCatalogModel>, QueryContainer> query = q => q.DateRange(d => d.GreaterThanOrEquals(startDate).LessThanOrEquals(endDate));
For example, one of methods:
public async Task GetCount(DateTimeOffset? startDate, DateTimeOffset? endDate, string eventName)
{
var count = await _elasticClient.CountAsync<OemCatalogModel>(c => c.Index(indexName)
.Query(query)
.Query(q => q.Match(m => m.Field(f => f.Event).Query($"{eventName}")))
);
}
What should signature of delegate for using this arguments? I trying implement following:
var count = await _elasticClient.CountAsync<OemCatalogModel>(c => c.Index(indexName)
.Query(query(startDate, endDate))
Upvotes: 0
Views: 87