Esempio n. 1
0
 public virtual void TestCriteriaQueryQueryWithValueInList2()
 {
     var baseName = GetBaseName();
     Init(baseName);
     var odb = Open(baseName);
     var p0 = new Profile("profile0");
     p0.AddFunction(new VO.Login.Function("f1"));
     p0.AddFunction(new VO.Login.Function("f2"));
     var p1 = new Profile("profile1");
     p0.AddFunction(new VO.Login.Function("f12"));
     p0.AddFunction(new VO.Login.Function("f22"));
     var user = new User("The user", "themail", p0);
     var user2 = new User("The user2", "themail2", p1);
     odb.Store(user);
     odb.Store(user2);
     odb.Close();
     odb = Open(baseName);
     var criteriaQuery = odb.Query<VO.Login.Function>();
     criteriaQuery.Descend("name").Constrain((object) "f2").Equal();
     var f2bis = criteriaQuery.Execute<VO.Login.Function>().GetFirst();
     var query = odb.Query<Profile>();
     query.Descend("functions").Constrain(f2bis).Contains();
     var l = query.Execute<Profile>();
     AssertEquals(1, l.Count());
     p1 = l.GetFirst();
     AssertEquals("profile0", p1.GetName());
     odb.Close();
 }
Esempio n. 2
0
        public virtual void TestCriteriaQueryQueryWithValueInList2_with_null_object()
        {
            var baseName = GetBaseName();
            Init(baseName);
            var odb = Open(baseName);
            var p0 = new Profile("profile0");
            p0.AddFunction(new VO.Login.Function("f1"));
            p0.AddFunction(new VO.Login.Function("f2"));
            p0.AddFunction(new VO.Login.Function("f12"));
            p0.AddFunction(new VO.Login.Function("f22"));

            var p1 = new Profile("profile1");

            var user = new User("The user", "themail", p0);
            var user2 = new User("The user2", "themail2", p1);
            odb.Store(user);
            odb.Store(user2);
            odb.Close();
            odb = Open(baseName);
            var f2bis = new VO.Login.Function("f2");
            var query = odb.Query<Profile>();
            query.Descend("functions").Constrain(null).Contains();
            var l = query.Execute<Profile>();
            //One from test, one from init
            AssertEquals(2, l.Count());
            p1 = l.First(x => x.GetName().Equals("profile1"));
            AssertEquals("profile1", p1.GetName());
            odb.Close();
        }