Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

I am reading a lot about Linq, but there are some parts that I can't figure out. Can anyone help me answering these questions?

Let say I have a Linq to SQL project and have attached a Access database to this. But in time I need to upgrade to the SQL server or MySql database. Do I then only need to adjust the connection string to the new database or do I need to rewrite the whole project?

Also is it possible to have connections to 2 or more diffent databases (rather same or different types of databases) in 1 project?

I have searching the internet verywhere but can't figure this out. All I can find ios that Linq can work with multiple type of databases, but none that is giving answers to my questions.

thanks,
Hans

What I have tried:

I have searching the internet to try to find the answers, but no luck sofar.
Posted
Updated 27-Oct-19 3:05am

1 solution

An ORM (Object Relational Mapper) helps to make your code database-agnostic.
Take a look at the free DevExpress XPO: orms-for-c[^]

If you don't want to use an ORM, read this: Don't hard code your DataProviders[^]
As this is an older article, there is no mention of LINQ, but I think the principles still can be useful nowadays.

About the term database-agnostic:
Quote:
Database-agnostic is a term describing the capacity of software to function with any vendor’s database management system (DBMS).
See: What is database-agnostic? - Definition from WhatIs.com[^]
 
Share this answer
 
v3
Comments
Member 13039327 27-Oct-19 13:28pm    
Hello RickZeeland,

Thanks for the reply. But I'm sorry, I'm not sure what you mean with database-agnostic. Do you mean that when I have used the ORM, I can attached any kind of database to it, without changing any coding (except maybe the connection string) ??

So if I create a project with ORM and use Access Database and later I want to go using a SQLServer database, I only need to change the connection string?

And also thanks for the link, don't hard code your dataProvider. But this is not about Linq, so I am not sure how it is being in Linq. If the code remains the same, regardless the type of database.

Regards,
Hans

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900