Dynamically Instantiate Model object in Entity Framework DB first by passing type as parameter

asp.net c# entity-framework entity-framework-6 linq

Question

Do you need to dynamically construct instances of the Entity Framework-generated Model class by supplying the table name as a parameter? (Model generated in DB first approach and using EF 6.0)

like,

// Input Param
string tableName 

// Context always same
DBContext dbContext= new DBContext(); 

//Need to create object query dynamically by passing 
//table name from front end as below  

 IQueryable<"tableName"> query = dbContext."tableName ";

Over 100 tables must be supplied as input parameters, and each table's structure is the same.

Thank you.

1
4
5/24/2017 1:00:44 PM

Accepted Answer

ZZZ_tmp
7
9/29/2017 2:28:17 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow