I have looked over the Repository pattern and I recognized some ideas that I was using in the past which made me feel well.
However now I would like to write an applicat
I did something similar with WCF
1 On your DBML, set you Serialization mode to Unidirectional
2 Set ALL columns on your tables to UpdateCheck=false
3 Write your service something like the following:
public class Service1 : IService1
{
public Company GetCompany(int companyId)
{
using (DataClasses1DataContext dc = new DataClasses1DataContext())
{
return (from c in dc.Companies where c.CompanyId == companyId select c).Single();
}
}
public void SaveCompany(Company company)
{
using (DataClasses1DataContext dc = new DataClasses1DataContext())
{
dc.Companies.Attach(company, true);
dc.SubmitChanges();
}
}
public void InsertCompany(Company company)
{
using (DataClasses1DataContext dc = new DataClasses1DataContext())
{
dc.Companies.InsertOnSubmit(company);
dc.SubmitChanges();
}
}
}
4 Add a service reference