public void MergeWithAny2() { Person person; using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { person = new Male("Test"); session.Save(person); transaction.Commit(); } person.AddHobby(new Hobby("Hobby_1")); person.AddHobby(new Hobby("Hobby_2")); using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { // the transient hobby "test" is inserted and updated person = session.Merge(person); transaction.Commit(); } using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { session.Delete(person); transaction.Commit(); } }
public async Task MergeWithAny2Async() { Person person; using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { person = new Male("Test"); await(session.SaveAsync(person)); await(transaction.CommitAsync()); } person.AddHobby(new Hobby("Hobby_1")); person.AddHobby(new Hobby("Hobby_2")); using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { // the transient hobby "test" is inserted and updated person = await(session.MergeAsync(person)); await(transaction.CommitAsync()); } using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { await(session.DeleteAsync(person)); await(transaction.CommitAsync()); } }
public void SaveOrUpdateCopyWithAny2() { Person person; using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { person = new Male("Test"); session.Save(person); transaction.Commit(); } person.AddHobby(new Hobby("Hobby_1")); person.AddHobby(new Hobby("Hobby_2")); using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { // the transient hobby "test" is inserted and updated person = (Person)session.SaveOrUpdateCopy(person); transaction.Commit(); } using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { session.Delete(person); transaction.Commit(); } }
public void MergeWithAny1() { Person person; using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { person = new Male("Test"); for (int i = 0; i < 10; i++) { person.AddHobby(new Hobby("Hobby_" + i.ToString())); } session.SaveOrUpdate(person); transaction.Commit(); } person.Hobbies.Clear(); using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { person = session.Merge(person); transaction.Commit(); } using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { session.Delete(person); transaction.Commit(); } }
public async Task MergeWithAny1Async() { Person person; using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { person = new Male("Test"); for (int i = 0; i < 10; i++) { person.AddHobby(new Hobby("Hobby_" + i.ToString())); } await(session.SaveOrUpdateAsync(person)); await(transaction.CommitAsync()); } person.Hobbies.Clear(); using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { person = await(session.MergeAsync(person)); await(transaction.CommitAsync()); } using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { await(session.DeleteAsync(person)); await(transaction.CommitAsync()); } }
public void SaveOrUpdateCopyWithAny1() { Person person; using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { person = new Male("Test"); for (int i = 0; i < 10; i++) { person.AddHobby(new Hobby("Hobby_" + i.ToString())); } session.SaveOrUpdate(person); transaction.Commit(); } person.Hobbies.Clear(); using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { person = (Person)session.SaveOrUpdateCopy(person); transaction.Commit(); } using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { session.Delete(person); transaction.Commit(); } }