vinay singri
vinay singri

Reputation: 199

Design Pattern which deals with loading databases

I am trying to write a windows service application which deals with storing values of an application into back end database.My design should be in such a way that user can select the back end database into which the records are to be written.So I was looking for one such design pattern in .net if available,which deals with connecting into multiple databases according to the user choice.

Upvotes: 0

Views: 320

Answers (2)

Muhammad Hasan Khan
Muhammad Hasan Khan

Reputation: 35146

Use Repository Pattern

public interface IDataStore
{
  void AddData(SomeData data);
}

this interface can be implemented for each target database. You can pick the implementation based on user choice. This has nothing to do with .NET though.

You can use Entity Framework to target multiple databases All you have to do is switch to the right ssdl file in the connection string based on user choice.

See Multiple database support with Entity Framework

Upvotes: 1

Tieson T.
Tieson T.

Reputation: 21231

Any .NET ORM will do this. LINQ-to-SQL, nHibernate, Entity Framework...

Upvotes: 1

Related Questions