views:

104

answers:

1

Is there a way in entity framework or linq to sql classes to map one class to many different tables with the same schema. For example if I have a database with thousands of tables for different stocks. All of the tables have the same columns. Is there a way I could have a base type class that could be used for mapping the data to an object. I obviously dont want to make thousands of different classes with just the table name being the difference. Also the tables change, ie new ones are added and names of some change from time to time. So idealy I would just have one class and when I request it I could pass in a symbol and it would map it to the correct table.

Thanks

+3  A: 

That seems to be a silly database design, and it's going to cause you more problems than just this. If all the data are the same, then they should be in a single table. Whether you partition the physical storage of that single table is a low-level implementation issue, not somthing that should show up in the schema.

I don't even know how you'd go about telling EF that you had added a new table, and it's to treat it like all the others. It just doesn't make too much sense.

John Saunders
Well putting every single tick of every single financial instrument into one table seems like really bad design to me. Then for every single request of data on a symbol you would have to filter that table vs just requesting one table
RBear
SQL Server and other DBMS' are good at "filtering". You'd simply have an index on the stock symbol and no other rows would be considered. This is what they _do_.
John Saunders
Yes you are right of course. db design is not normally my focus. thanks
RBear