Controller action parameter that implements an ICollection interface

46 views Asked by At

So I'm trying to call a controller action like this:

Public Task<IActionResult> DoSomething([FromBody] container)
{...}
public record container {
  public collection<Product> collection;
}
public record collection(ICollection<T> data) : ICollection<T> where T : Product
{
   ...ICollection implementation methods here
}

The problem is that once the collection inherits ICollection the controller cannot parse the request. But once the collection record looks like :

public record collection(ICollection<T> data) where T : Product

Then parsing works.

Is there a way to tell the parser to use the record constructor instead of the default way it works?

0

There are 0 answers