0
votes

I am looking for the closest idea on Microsoft plataform (IIS + .Net Framework or . Net CORE) that resembles the Java DataSource.

A little bit of context for those who don“t know DataSource. Datasource abstract the concept of Database configuration for the application. In Java (using it as example) if I have an application that demands connection with a database a good approach is to create a datasource.

The datasource defines the connection string for the underlying database, the user and password used to connect to the database and many other parameters like size of connection pool. The datasource has a name to be used by the application to look up. In Java it is named JNDI and it is a string, so the application looks for the datasource named java:jboss/datasources/ExampleDS.

This gives a big advantage on decoupling the consumer from the source. So, when I deploy my application in a test environment when the application looks after java:jboss/datasources/ExampleDS this datasource (created in a java application server) is pointing to a dev database. When I deploy the same package on QA application server the java:jboss/datasources/ExampleDS points to QA database and the same on PROD.

What should I do on IIS or any other microsoft technology/plataform/solution to have the same transparency?

enter image description here

1

1 Answers

0
votes

There are many object-relation mapping (ORM) tools available in .NET that will achieve what you have described. Two of the more popular ones are Entity Framework and Dapper.

Some people don't like the abstraction those two provide (even though they are actually data source independent) and so some people will implement the unit of work design pattern. If you are looking for a good read on how to get started with that, check out Jason Watmore's blog.

You may also want to look at MediatR as well. There a lot of options, it will just depend on your preference and requirements for the implementation.