kevin hajj
kevin hajj

Reputation: 1

C# dynamic List to send to sql stored procedure

I have a List<T> in my c# code. What I want is that I have an api called Employee/GetAllEmployees. Request parameter is

{
  "page": 0,
  "pageSize": 0,
  "search": "string",
  "filterBy": [{
    "key": "idEmployee",
    "value": ["3fa85f64-5717-4562-b3fc-2c963f66afa6"]
  }, {
    "key": "firstName",
    "value": ["abc", "def"]
  }, {
    "key": "mode",
    "value": [1, 2]
  }],
  "orderBy": [{
    "key": "lastName",
    "value": "asc"
  }, {
    "key": "firstName",
    "value": "desc"
  }]
}

The problem is that I want to send to the stored procedure dynamic type depends on the coming request. Is there a way to handle such scenario, and how??
I can create user defined table type in the sql and put this type as request params in the stored procedure, but what about dynamic type?

I have tried to make different list in the request model. I created List<int, int> for the integer columns in the datatable, then I created List<string, string> for the string columns in the datatable and so on. So for example, if i want to filter for the date values, i need to create List for this specific type

Upvotes: 0

Views: 192

Answers (0)

Related Questions