Question Get all tables from database and loop through each table


New member
Jul 21, 2012
Programming Experience
Hi ,

I have sql server 2012 database with 12 tables (excluding look up tables). i am using entity frame work and trying to query. i am able to query a table

ClientEntities dc = new ClientEntities();
var query = from client1 in dc.CLIENTTable
where client1.CLIENT_ID == txtId.Text
select client1;

above works for 1 table but i need to do it for all the 12 tables. Is there a way to do it in loop
As far as I'm aware and as far as I can tell, an EF model has no property that contains a collection of all EntitySets. You could use Reflection and test each property to see if its type is EntitySet but I would think that just hard-coding it would be the way to go.
Top Bottom