Custom Collection extends List<T> Add method
I want to create a custom collection and add my own custom Add method. Scenario:
Teacher.Students.Add(Student s)
I want to put LINQ m开发者_运维技巧ethods to save the teacher/student relationship to the database, not just add it to the list.
How can I do that? How can I know what "Teacher" object this is?
Your best bet is to set up and configure an ORM (Object-relational mapping), such as NHibernate, that will manage this for you. In effect, you set up the data model, and the ORM framework will take care of persisting that information for you.
精彩评论