public void Merge() { object clubId; using (ISession s = OpenSession()) { Club club1 = new Club(); clubId = s.Save(club1); s.Flush(); } Clubmember mem = new Clubmember(); ISession sess2 = OpenSession(); mem.Club = (Club)sess2.Get(typeof(Club), clubId); sess2.Close(); ISession sess = OpenSession(); mem.Expirydate = DateTime.Now.AddYears(1); mem.Joindate = DateTime.Now; sess.Merge(mem); sess.Flush(); sess.Close(); using (ISession s = OpenSession()) { s.Delete("from System.Object"); s.Flush(); } }
public void SaveOrUpdateCopy() { object clubId; using (ISession s = OpenSession()) { Club club1 = new Club(); clubId = s.Save(club1); s.Flush(); } Clubmember mem = new Clubmember(); ISession sess2 = OpenSession(); mem.Club = (Club) sess2.Get(typeof(Club), clubId); sess2.Close(); ISession sess = OpenSession(); mem.Expirydate = DateTime.Now.AddYears(1); mem.Joindate = DateTime.Now; sess.SaveOrUpdateCopy(mem); sess.Flush(); sess.Close(); using (ISession s = OpenSession()) { s.Delete("from System.Object"); s.Flush(); } }
public async Task MergeAsync() { object clubId; using (ISession s = OpenSession()) { Club club1 = new Club(); clubId = await(s.SaveAsync(club1)); await(s.FlushAsync()); } Clubmember mem = new Clubmember(); ISession sess2 = OpenSession(); mem.Club = (Club)await(sess2.GetAsync(typeof(Club), clubId)); sess2.Close(); ISession sess = OpenSession(); mem.Expirydate = DateTime.Now.AddYears(1); mem.Joindate = DateTime.Now; await(sess.MergeAsync(mem)); await(sess.FlushAsync()); sess.Close(); using (ISession s = OpenSession()) { await(s.DeleteAsync("from System.Object")); await(s.FlushAsync()); } }