Which layer is the best layer to make linq-sql calls as SubmitChanges(), InsertOnSubmit() etc.
For example, let's say I have two tables Parent and Child. Child table has foreign key on parent (Child table has ParentId column). I want to insert parent object and child objects into the db.
Using linq-sql, I can do this.
Parent parent = new Parent();
Child child1 = new Child();
Child child2 = new Child();
//assign values to parent data members
//...
parent.Childs.Add(child1);
parent.Childs.Add(child2);
using (DataContext db = new DataContext())
{
db.Parents.InsertOnSubmit(parent);
db.SubmitOnChanges();
}
Am I mixing Presentation layer code with data access layer? If so, how do I do it with a business layer object in between?
Please let me know. Thanks.