Hi all,
Currently I'm trying to implement LINQ to SQL in my project. I'm trying to use LINQ to SQL with the famous repository pattern. here is what I was trying to do:
- Create table, for example customer table.
- Generate LINQ to SQL (.dbml) for my customer table.
- It generated partial Customer class complete with all the properties and some partial method.
After that I need to put some custom method for ex: GetCustomerById(int id), GetCustomerByName(string name), etc. So I create a partial class of Customer and implement all the function that I need.
Hmmm, from this step I realized that there is something weird that I haven't implemented the repository pattern.. T_T
What I was trying to do was create a business layer that access repository layer, and then repository layer use LINQ to SQL as data model and data access to SQL Server. Is this the best practice? and how to add repository pattern to my customer partial class generated by LINQ to SQL?
Thanks.