I have a foreach which will call severel views, and i try to laod this views dynamically into the dbContext of entity framework.
What I have so fare is :
var context = new DbContext();
var type = Type.GetType($"XXX.XXXXXXX.XXXX.XXXXX.{exportItem.DataSourceView}, XXX.XXXXXXX.XXXX.XXXXX");
context.Set(type).Load();
var result = context.Set(type).AsQueryable().Cast<View_DataLoad>().ToList();
This works so far, but I have to Cast the result to the class which I set to the dbContext.
How can I add dynamically class to the cast function?
Or is there a better way to load dynamically query's to the entity framework?
Thanks for help.
Aucun commentaire:
Enregistrer un commentaire