lundi 10 mai 2021

Could I return a class as return of a method?

My problem is, I created a WebApi in asp.net. My models sent to my repository data from my class Person. But I want to persist in database in two different collections (I'm using MongoDB).

For this purpose I made an static method as it follows:

public static Type ReturnAsCollection(PersonTypeDelegate predicatee) 
        {

            if (predicatee.ToString().Equals(typeof(Infectados).Name.Substring(0)))
                return Type.GetType(typeof(Infectados).Name);
            else 
                return Type.GetType(typeof(Vacinados).Name);
        }

But the return is always null.

So, how could I return a Type in this case? There's another way to validate a class and throw it as a parameter?





Aucun commentaire:

Enregistrer un commentaire