I need to dynamically access some SQL tables, hoping using Entity Framework. Here are a few pseudo codes:
var Account = DB.Accounts.SingleOrDefault(x => x.ID == 12345);
which will return an Account object to me, and it contains some fields called "PREFIX", "CAMPAIGN ID", and additional information about accounts is stored in separate SQL tables with the naming convention PREFIX_CAMPAIGNID_MAIN.
All tables have the same fields, so I thought about creating a new object that is not displayed anywhere, and then dynamically loads it, for example:
var STA01_MAIN = new MyAccount(); // my "un-mapped" entity
DB.LoadTable('STA01_MAIN').LoadInto(STA01_MAIN);
Now I can get something about the STA01_MAIN account: STA01_MAIN.AccountId .
So my question is: how do I access these tables using the Entity Framework?
source share