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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…