mardi 20 octobre 2015

Generic FetchDictionary method for petapoco

PetaPoco has this method :

public List<T> Fetch<T>(string sql, params object[] args) 
    {
        return Query<T>(sql, args).ToList();
    }

I want to create a method like this :

        public Dictionary<Guid, T> FetchDict<T>(string sql, params object[] args)
    {
//What goes here ?
        return Query<T>(sql, args).ToDictionary(x => ???, x => x);
    }

In the stub above, it should use reflection & use the PrimaryKey attribute and set that field as key. How can I do this ?





Aucun commentaire:

Enregistrer un commentaire