Generic Repository with SQL

1

Seeing this question: Here

I was wondering if it's possible / right to use an equal scheme in a project where I do not use some framework for connecting to a bank.

I would like an example of the correct way to have a DAL layer, in which it communicates with SQL SERVER.

Do I really need to have a method for all my interactions with the bank?

    
asked by anonymous 21.09.2014 / 17:27

2 answers

3

Yes, it is possible.

I gave an example of generic DAL here . Actually the idea is a DAL that looks a lot like a repository, since the basic operations are generated from the class passed to the common class. Other operations can be written to classes derived from Comum .

However, it is important to say that this method is rather long-winded and will take some time to write operations that are not trivial (for example, a% with% with% of%, and the assembly of objects for the layer that requested the data). Or, worst of all, you can work with% direct%, which is the worst approach possible.

    
21.09.2014 / 21:39
3

It is not mandatory to use a layer only for interaction with the database. It's a lot of the project you're developing.

For example, if you are building a simple application, a To-Do List or a project with very few tables or entities, and you or someone sure will not need to include new features in the future, I do not see that it is necessary to waste time with the data layer.

On the other hand, if your project has the potential to grow (include new features, frequent changes, among others) I recommend to look fondly at the beginning of the project in a layer of repositories for your application, just to isolate the logic of the business the implementation of the bank. This will bring much more ease to evolve your application.

    
21.09.2014 / 17:59