public Project SaveProject( ) { Project project; using( ISession session = OpenSession( ) ) using( ITransaction tx = session.BeginTransaction( ) ) { //Create a project scenario project = new Project( ); Scenario scenario1 = new Scenario( ); Scenario scenario2 = new Scenario(); Scenario scenario3 = new Scenario(); //Add the scenario to all lists project.ScenarioList1.Add(scenario1); project.ScenarioList2.Add(scenario2); project.ScenarioList3.Add(scenario3); //Set the primary key on the project project.Name = "Test"; //Save the created project session.Save( project ); tx.Commit( ); } return project; }
public void RefreshProject(Project project) { using (ISession session = OpenSession()) using (ITransaction tx = session.BeginTransaction()) { //The project is refreshed and Scenario1, Scenario2 and Scenario3 properties can be set //This will succeed when the scenario list is set and accessed during the set but only for //Scenario 2 and Scenario3. It will fail if the scenario list is accessed during the set for Scenario1 session.Refresh(project); } }