public void LinqExploratoryTestWhichProvesNothing() { { var i1001 = new MyRef1 { Id = 1001, I1 = null, I2 = 101 }; var i1101 = new MyRef1 { Id = 1101, I1 = null, I2 = 111 }; var i1002 = new MyRef1 { Id = 1002, I1 = 12, I2 = 102 }; var i1003 = new MyRef1 { Id = 1003, I1 = 13, I2 = 103 }; var ref1s = new[] { i1001, i1101, i1002, i1003 }; var someRef1s = from r in ref1s orderby(r.Id == 1101 || r.Id == 1102?r.Id - 1000 : r.Id) select(r.Id == 1101 || r.Id == 1102 ? r.Id + 1000 : r.Id); CollectionAssert.AreEqual(new[] { 2101, 1001, 1002, 1003 }, someRef1s.ToList()); } { var j2001 = new MyRef2 { Id = 2001, J1 = null, J2 = 201 }; var j2002 = new MyRef2 { Id = 2002, J1 = 22, J2 = 202 }; var i1001 = new MyRef1 { Id = 1001, I1 = null, I2 = 101, BO2 = j2001 }; var i1002 = new MyRef1 { Id = 1002, I1 = 12, I2 = 102, BO2 = null }; var b10 = new MyBO { Id = 10, Name = "1:1001,o1:NULL,2:NULL", BO1 = i1001, OtherBO1 = null, BO2 = null }; var b20 = new MyBO { Id = 20, Name = "1:1002,o1:NULL,2:2002", BO1 = i1002, OtherBO1 = null, BO2 = j2002 }; var bos = new[] { b10 }; //var someBos = from r in bos // where r.BO1.BO2.J2 == 201 // select r; //CollectionAssert.AreEqual(new[] { b10 }, someBos.ToList()); var someBos1 = from r in bos where (r.BO1.BO2 == null ? r.BO2 : r.BO1.BO2).J2 == 201 select r.Id; Assert.That(() => someBos1.ToList(), Is.EquivalentTo(new[] { b10.Id })); } }
private async Task <MyRef2> GetOrCreateBO2Async(ISession s, CancellationToken cancellationToken = default(CancellationToken)) { if (BO2 == null) { BO2 = new MyRef2(); await(s.SaveAsync(BO2, cancellationToken)); } return(BO2); }
public virtual MyRef2 GetOrCreateBO2(ISession s) { if (BO2 == null) { BO2 = new MyRef2(); s.Save(BO2); } return BO2; }
public virtual MyRef2 GetOrCreateBO2(ISession s) { if (BO2 == null) { BO2 = new MyRef2(); s.Save(BO2); } return(BO2); }
private MyRef2 GetOrCreateBO2(ISession s) { if (BO2 == null) { BO2 = new MyRef2(); s.Save(BO2); } return(BO2); }
/// <summary> /// This setup is used in most tests in here - but not all; and we might want to /// twist it for special tests. Therefore, the OnSetUp mechanism is not used. /// </summary> /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param> private async Task StandardSetUpAsync(CancellationToken cancellationToken = default(CancellationToken)) { using (var session = OpenSession()) { using (var tx = session.BeginTransaction()) { var i1001 = new MyRef1 { Id = 1001, I1 = null, I2 = 101 }; var i1101 = new MyRef1 { Id = 1101, I1 = null, I2 = 111 }; var i1002 = new MyRef1 { Id = 1002, I1 = 12, I2 = 102 }; var i1003 = new MyRef1 { Id = 1003, I1 = 13, I2 = 103 }; await(session.SaveAsync(i1001, cancellationToken)); await(session.SaveAsync(i1101, cancellationToken)); await(session.SaveAsync(i1002, cancellationToken)); await(session.SaveAsync(i1003, cancellationToken)); var j2001 = new MyRef2 { Id = 2001, J1 = null, J2 = 201 }; var j2002 = new MyRef2 { Id = 2002, J1 = 22, J2 = 202 }; var j2003 = new MyRef2 { Id = 2003, J1 = null, J2 = 203 }; await(session.SaveAsync(j2001, cancellationToken)); await(session.SaveAsync(j2002, cancellationToken)); await(session.SaveAsync(j2003, cancellationToken)); var b10 = new MyBO { Id = 10, Name = "1:1001,o1:NULL,2:NULL", BO1 = i1001, OtherBO1 = null, BO2 = null }; var b11 = new MyBO { Id = 11, Name = "1:1001,o1:1101,2:NULL", BO1 = i1001, OtherBO1 = i1101, BO2 = null }; var b20 = new MyBO { Id = 20, Name = "1:1002,o1:NULL,2:2002", BO1 = i1002, OtherBO1 = null, BO2 = j2002 }; var b30 = new MyBO { Id = 30, Name = "1:NULL,o1:NULL,2:2003", BO1 = null, OtherBO1 = null, BO2 = j2003 }; await(session.SaveAsync(b10, cancellationToken)); await(session.SaveAsync(b11, cancellationToken)); await(session.SaveAsync(b20, cancellationToken)); await(session.SaveAsync(b30, cancellationToken)); await(tx.CommitAsync(cancellationToken)); } } }
/// <summary> /// This setup is used in most tests in here - but not all; and we might want to /// twist it for special tests. Therefore, the OnSetUp mechanism is not used. /// </summary> private void StandardSetUp() { using (var session = OpenSession()) { using (var tx = session.BeginTransaction()) { var i1001 = new MyRef1 { Id = 1001, I1 = null, I2 = 101 }; var i1101 = new MyRef1 { Id = 1101, I1 = null, I2 = 111 }; var i1002 = new MyRef1 { Id = 1002, I1 = 12, I2 = 102 }; var i1003 = new MyRef1 { Id = 1003, I1 = 13, I2 = 103 }; session.Save(i1001); session.Save(i1101); session.Save(i1002); session.Save(i1003); var j2001 = new MyRef2 { Id = 2001, J1 = null, J2 = 201 }; var j2002 = new MyRef2 { Id = 2002, J1 = 22, J2 = 202 }; var j2003 = new MyRef2 { Id = 2003, J1 = null, J2 = 203 }; session.Save(j2001); session.Save(j2002); session.Save(j2003); var b10 = new MyBO { Id = 10, Name = "1:1001,o1:NULL,2:NULL", BO1 = i1001, OtherBO1 = null, BO2 = null }; var b11 = new MyBO { Id = 11, Name = "1:1001,o1:1101,2:NULL", BO1 = i1001, OtherBO1 = i1101, BO2 = null }; var b20 = new MyBO { Id = 20, Name = "1:1002,o1:NULL,2:2002", BO1 = i1002, OtherBO1 = null, BO2 = j2002 }; var b30 = new MyBO { Id = 30, Name = "1:NULL,o1:NULL,2:2003", BO1 = null, OtherBO1 = null, BO2 = j2003 }; session.Save(b10); session.Save(b11); session.Save(b20); session.Save(b30); tx.Commit(); } } }
private MyRef2 GetOrCreateBO2(ISession s) { if (BO2 == null) { BO2 = new MyRef2(); s.Save(BO2); } return BO2; }