I am developing an MVC 5 application. I query on my database as:
var result = db.ABCs.AsNoTracking().FirstOrDefault(e => e.Id == Id);
But what if I want to make a generic method and Don't know the name of the model on compile time. I want to query on any model class that is passed to a method at runtime. Something as :
var result = db.<T>.Where(x => x.Id == Id).ToList();
How can I do that. I am using database first approach and no repositories or UoW.
Aucun commentaire:
Enregistrer un commentaire