lundi 17 avril 2023

How to pass array of objects type in MediatoR patterns?

Hope You are doing well!

I am using MediatoR design pattern in which i want to accept array of collections as an object in my controller. Earlier i was using as a single object but now how can i allow the MediatoR to accept array as parameter.

From: public async Task<ActionResult<ServiceResponse>> AddField(AddFieldCommand objFieldCommand)

To: public async Task<ActionResult<ServiceResponse>> AddField(AddFieldCommand[] objFieldCommand)

I tried doing this but it is giving me the below error:

Severity    Code    Description Project File    Line    Suppression State
Error   CS0311  The type 'Application.Commands.Fields.AddFieldCommand[]' cannot be used as type parameter 'TRequest' in the generic type or method 'IRequestHandler<TRequest, TResponse>'. There is no implicit reference conversion from 'Application.Commands.Fields.AddFieldCommand[]' to 'MediatR.IRequest<Application.Common.ServiceResponse<int>>'.   Application C:\Users\Admin\Documents\Projects\Source Code\Application\Commands\Fields\AddFieldCommand.cs    28  Active

Can any one please help me?

Aucun commentaire:

Enregistrer un commentaire