Skip to content

CommonParameters a way to handle SearchParams

verzada edited this page Aug 17, 2017 · 2 revisions

Why is it there?

CommonParameters is a way to handle SearchParameters which are sent to the service. We realized rather quickly that we needed some convenient way of handling parameters, so therefore we came up with a class that takes all the parameters we have used so far in our services and exposes the parameters as attributes in an object.

By doing so, it is far easier to use the parameters when querying data sources. We're especially fan of using the object along with Entity Framework.

It's worth noting that the CommonParameters class is more a convenience than a necessity, so therefore we haven't used in any of our examples. Plus the CommonParameters class attributes are rather lacking since it's hard to incorporate all the possible attributes from all of the Resources with a decent level of quality.

How to use CommonParameters

Basically you just need to initialize the object with your received SearchParameters and you are good to go. The CommonParameters class will figure out the most common properties and expose the attributes, however if you need attributes we don't use, we'd recommend either inheriting the class or make your own.

    var parameters = new CommonParameters(searchParams);