I have used the Subsonic3 Linq T4 templates to generate data access code for my database. The one table I have so far represents a class very much like the following.
public class NavigationItem
{
int ID {get;set;} // Auto generated field in database
int ParentId {get;set;} // equal to ID if this is a top level navigation
string Name {get;set;}
string Url {get;set;}
// foreign key from ParentId --> ID
IQueryable<NavigationItems> NavigationItems {get;}
}
I can work out how to use the generated code to select items from the database, however I'm not so sure about how to insert - particularly with inserting the Child items (and their Children's children etc.).
How would you go about inserting a NavigationItem to the database (including it's children, and children's children etc.)