I am working with a very old database (unchangeable) which is not normalised very well. Because of this, the software we use must add and remove tables from time to time.
There is one table which keeps track of which other tables exist (I know, not pretty but thats what I have to work with).
How can I create a DataContext properly when I cannot know beforehand which tables exist? Can the mapping to objects be done programmatic-ally at runtime?
Ak
.NET ProgrammingC#
Last Comment
kingy0489
8/22/2022 - Mon
Fernando Soto
Hi kingy0489;
You say that, "I am working with a very old database", unless the server you are using is not Microsoft SQL Server you can't use Linq to SQL because it only supports MS SQL Server currently. The Linq to Entity implementation supports multiple types of database servers as long as there is an implementation for it. Either of the two implementations requires you to know at design time the database information such as tables names and columns and so on. So in answer to your question, no, you need the information in order to build a strongly typed model to program with.
Fernando
kingy0489
ASKER
Sorry, the database is 5 years old, so not massively old, running on SQL Server 2005, it predates my time at this company and I am told it needs to remain as is for legacy reasons.
Would you suggest I use LINQ for the tables I do know of, and come up with something else for the other tables?
You say that, "I am working with a very old database", unless the server you are using is not Microsoft SQL Server you can't use Linq to SQL because it only supports MS SQL Server currently. The Linq to Entity implementation supports multiple types of database servers as long as there is an implementation for it. Either of the two implementations requires you to know at design time the database information such as tables names and columns and so on. So in answer to your question, no, you need the information in order to build a strongly typed model to program with.
Fernando