lundi 23 avril 2018

Is it possible to create a method for dynamic generics c#?

Is it possible to make these methods as one generic method where I can pass in a dynamic number of TJoins? I'm pretty sure you can't the way I want to, but was wondering if anyone know a work around such as using reflection?

Thanks.

    public IEnumerable<TReturn> Select<TReturn, TJoin1>(string query, Func<TReturn, TJoin1, TReturn> join)
    {
        using (IDbConnection db = _connector.GetConnection())
        {
            return db.Query(query, join);
        }
    }

    public IEnumerable<TReturn> Select<TReturn, TJoin1, TJoin2>(string query, Func<TReturn, TJoin1, TJoin2, TReturn> join)
    {
        using (IDbConnection db = _connector.GetConnection())
        {
            return db.Query(query, join);
        }
    }





Aucun commentaire:

Enregistrer un commentaire