-
Couldn't load subscription status.
- Fork 44
Open
Labels
filtersStories related to queries and filters.Stories related to queries and filters.good first issuegroomedThe issue has been groomed and should be in a good shape.The issue has been groomed and should be in a good shape.hacktoberfesthelp wantedup-for-grabs
Description
Motivation
When using filters, the developer always specifies the element or attribute path (the predicate) and a value to filter by. The value has to be formatted specifically in order for the SDK to understand it.
Design guidelines
- Create a generic
Filterclass that will acceptTinstead ofstringfor thevalueparameter in its constructor - The
Filterclass will storeTs instead ofstrings in theValuesproperty - Add
DateTimeanddecimalconstructors to all applicable filters. - The constructors will utilize the updated constructor of
Filterthat acceptsobjects as values - The
GetQueryStringParameter()method ofFilterwill use pattern matching to distinguish between various types and will behave according to the specification:- format
DateTimevalues to ISO-8601 - format numeric types (int, float...) to
"##########.##########" - treat all other types as strings and perform the current behavior
- format
Example
public string GetQueryStringParameter()
{
IEnumerable<string> values = Values switch
{
DateTime[] dates => values = dates.Select(d => d.ToString("o")),
int[] numbers => numbers.Select(n => n.ToString()),
_ => Values.Select(v => v.ToString())
};
var op = Uri.EscapeDataString(Operator ?? string.Empty);
var element = Uri.EscapeDataString(ElementOrAttributePath);
var escapedValues = string.Join(SEPARATOR, values.Select(Uri.EscapeDataString));
return string.Format($"{element}{op}={escapedValues}");
}
References
- Original discussion: Generic filters #27
Pattern matching:
Metadata
Metadata
Assignees
Labels
filtersStories related to queries and filters.Stories related to queries and filters.good first issuegroomedThe issue has been groomed and should be in a good shape.The issue has been groomed and should be in a good shape.hacktoberfesthelp wantedup-for-grabs