Well, I always try to improve the coding method, because it is my passion. I have a .dbml file ( LINQ to SQL ) and I use it to access the SQL Server database .
Imagine, if you want, that you have a Person table in your database, and you want to provide a way to delete, add, and modify a Person record.
I am currently developing classes called PersonRepository, CarRepository, DocumentRepository, etc. For each table in my database, I create a repository class.
These repository classes usually consist of something like this:
MyDatabaseContext db = new MyDatabaseContext(); public Person GetPersonByID(int id) { return db.Person.Where(p => p.ID == id); }
Quite the same for the basic CRUD functions for each table.
If I need something more specific, for example, βSergio, I need a list of all people born between x and yβ; then I just add this method to the PersonRepository class.
public List<Person> GetPeopleFromDOB(DateTime x, DateTime y) {
Another idea I had was to create the DataAccess.cs class and use all of these methods (we will talk about 4-5 methods for existing tables) and share them by region.
What do more experienced programmers do and what suggestions do you offer for a young programmer (Iβm 20 years old)?