lundi 20 août 2018

Passing a dynamic where clause through Web API

I am currently in the process of creating a.NET Core Web API that is going to interact with an Angular front end. There is a requirement for the web API to be able to return data based on a dynamically built where statement. For example, I have an object with the following model

{
    "accountCode": "ABC123",
    "addressLine1": "AddressLine1",
    "addressLine2": "AddressLine2",
    "addressLine3": "AddressLine3",
    "addressLine4": null,
    "addressLine5": null,
    "businessUnitName": "",
    "companyRegistrationNumber": null,
    "name": "My supplier",
    "postcode": "BA112RP",
    "supplierId": 3,
    "vatRegistrationNumber": null
}

Now rather than having my controller method setup with 12 different parameters and needing to add an extra parameter whenever I add a new property is there a way I can have a dynamic parameter (KeyValuePair type arrangement)?




Aucun commentaire:

Enregistrer un commentaire