I'm newbie C# developer. After I simply have began to understand programming thins were really quite simple, the thing is the issue, you develop solution, test drive it and delay pills work, that easy.

Then you definitely discover the look designs and also the whole abstraction factor, and also you start to take more time around the code that yields no results, always tiring to safeguard code from possible alterations in future. Additional time less result.

Sorry for that boring introduction, however i just attempting to show how frustrated I'm now. There's a lot of data-access technologies supplied by Microsoft itself, as well as bigger couple of technologies supplied by third-party companies.

I do not have team leader or neighbor super skilled programmer friend, so I must request a guidance of your stuff.

How can you realize the information access inside your real programs designed in C#?

From the very overall perspective, I usually hide and data access implementation particulars behind an interface, such as this:

public interface IRepository<T> { /*...*/ }

The .Internet framework offers lot of different methods to access data, in order to understand that you're confused. However, at this time around, you will find only really 2 or 3 reasonable choices for being able to access relational databases:

It's frequently hard to see the advantage of abstraction without seeing the advantages it offers inside a real life application. The best way forward I'm able to give would be to educate yourself around the SOLID concepts then on paper the application try to consider ways the customer may come your way and say "Now I want it to get this doneInch which perhaps a subtle switch to the functionality or perhaps a major change. Consider how this could affect your code as well as in the number of places you'd desire to make individuals changes. Once you have made individuals changes how confident will you be that you simply haven't damaged another thing?

Also try this is always to download among the sample programs. Among my particular favourites may be the Data Access Platform sample provided on Codeplex. Try dealing with this code and find out the way the abstraction and pattern implementations minimise the effect on the code overall when the time comes to alter.

The end result is it's not hard to become familiar with a programming language but learning how to build robust solutions by using it needs time to work. Stick to it though because whenever you do finally obtain a good knowledge of software architecture it's hugely rewarding.

Some facts to consider for that DAL: (note: very opinionated, but solutions for this question need to be)

  • Encapsulate logic behind a Repository
  • Use interfaced-based coding
  • Use Dependency Injection
  • Make use of a mature ORM like NHibernate/Entity Framework 4. (but know when you should use SPROC's for db-intensive work)
  • Make use of the Unit of labor pattern
  • Prevent SQL Injection attacks by utilizing parameterized queries (or LINQ-Entites, as above)