示例#1
0
        public virtual void TestDate1()
        {
            string baseName = GetBaseName();

            SetUp(baseName);
            NeoDatis.Odb.ODB odb = Open(baseName);
            NeoDatis.Odb.Test.Query.Criteria.MyDates myDates = new NeoDatis.Odb.Test.Query.Criteria.MyDates
                                                                   ();
            System.DateTime d1 = new System.DateTime();
            Thread.Sleep(100);

            System.DateTime d2 = new System.DateTime();
            Thread.Sleep(100);
            System.DateTime d3 = new System.DateTime();
            myDates.SetDate1(d1);
            myDates.SetDate2(d3);
            myDates.SetI(5);
            odb.Store(myDates);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery
                                                       (typeof(MyDates), Where
                                                       .And().Add(Where.Le("date1", d2)).Add(Where
                                                                                             .Ge("date2", d2)).Add(Where.Equal("i", 5)));
            NeoDatis.Odb.Objects <MyDates> objects = odb.GetObjects <MyDates>(query);
            AssertEquals(1, objects.Count);
            odb.Close();
        }
示例#2
0
        public virtual void Test3()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            int size             = 500;

            for (int i = 0; i < size; i++)
            {
                odb.Store(new Class1("c1"));
            }
            for (int i = 0; i < size; i++)
            {
                odb.Store(new Class1("c2"));
            }
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Core.Query.IQuery q = new CriteriaQuery();
            // q.orderByAsc("name");
            NeoDatis.Odb.Objects <Class1> objects = odb.GetObjects <Class1>(q);
            AssertEquals(size * 2, objects.Count);
            for (int i = 0; i < size; i++)
            {
                Class1 c1 = (Class1
                             )objects.Next();
                AssertEquals("c1", c1.GetName());
            }
            for (int i = 0; i < size; i++)
            {
                Class1 c1 = (Class1
                             )objects.Next();
                AssertEquals("c2", c1.GetName());
            }
            odb.Close();
        }
示例#3
0
        public virtual void Test4()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            int size             = 5;

            for (int i = 0; i < size; i++)
            {
                odb.Store(new Function("f" + (i + 1)));
            }
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Core.Query.IQuery q = new CriteriaQuery();
            // q.orderByAsc("name");
            NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(q, true, 0, 2);
            AssertEquals(2, objects.Count);
            odb.Close();
            odb = Open(baseName);
            q   = new CriteriaQuery();
            q.OrderByAsc("name");
            objects = odb.GetObjects <Function>(q, true, 0, 2);
            AssertEquals(2, objects.Count);
            odb.Close();
            odb = Open(baseName);
            q   = new CriteriaQuery();
            q.OrderByDesc("name");
            objects = odb.GetObjects <Function>(q, true, 0, 2);
            AssertEquals(2, objects.Count);
            odb.Close();
        }
示例#4
0
文件: TestMap.cs 项目: ekicyou/pasta
        public virtual void Test5updateIncreasingSize()
        {
            NeoDatis.Odb.ODB odb = Open("map.neodatis");
            long             n   = odb.Count(new CriteriaQuery(typeof(
                                                                   NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)));

            NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery
                                                       (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), Where
                                                       .Equal("name", "test2"));
            NeoDatis.Odb.Objects <Dictionnary> l = odb.GetObjects <Dictionnary>(query);
            NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary
                                                                               )l.GetFirst();
            dictionnary.SetMap(null);
            odb.Store(dictionnary);
            odb.Close();
            odb = Open("map.neodatis");
            AssertEquals(n, odb.Count(new CriteriaQuery
                                          (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))));
            NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary
                                                                       )odb.GetObjects <Dictionnary>(query).GetFirst();
            AssertNull(dic.GetMap());
            odb.Close();
            odb = Open("map.neodatis");
            dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)odb.GetObjects <Dictionnary>(query).GetFirst();
            dic.AddEntry("olivier", "Smadja");
            odb.Store(dic);
            odb.Close();
            odb = Open("map.neodatis");
            dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)odb.GetObjects <Dictionnary>(query).
                  GetFirst();
            AssertNotNull(dic.GetMap());
            AssertEquals("Smadja", dic.GetMap()["olivier"]);
            odb.Close();
        }
示例#5
0
文件: TestMap.cs 项目: ekicyou/pasta
        public virtual void Test6updateDecreasingSize()
        {
            NeoDatis.Odb.ODB odb = Open("map.neodatis");
            long             n   = odb.Count(new CriteriaQuery(typeof(
                                                                   NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)));

            NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery
                                                       (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), Where
                                                       .Equal("name", "test2"));
            NeoDatis.Odb.Objects <Dictionnary> l = odb.GetObjects <Dictionnary>(query);
            NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary
                                                                               )l.GetFirst();
            int mapSize = dictionnary.GetMap().Count;

            dictionnary.GetMap().Remove("f1");
            odb.Store(dictionnary);
            odb.Close();
            odb = Open("map.neodatis");
            AssertEquals(n, odb.Count(new CriteriaQuery
                                          (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))));
            NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary
                                                                       )odb.GetObjects <Dictionnary>(query).GetFirst();
            AssertEquals(mapSize - 1, dic.GetMap().Count);
            odb.Close();
        }
示例#6
0
        public virtual void Test4Sort()
        {
            string baseName = GetBaseName();

            SetUp(baseName);
            int d = NeoDatis.Odb.OdbConfiguration.GetDefaultIndexBTreeDegree();

            try
            {
                NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(40);
                NeoDatis.Odb.ODB odb = Open(baseName);
                CriteriaQuery    aq  = new CriteriaQuery
                                           (typeof(Function), Where
                                           .Not(Where.Or().Add(Where
                                                               .Equal("name", "function 2")).Add(Where.Equal("name"
                                                                                                             , "function 3"))));
                aq.OrderByDesc("name");
                // aq.orderByAsc("name");
                NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(aq, true, -1, -1);
                odb.Close();

                AssertEquals(48, l.Count);
                Function f = (Function)l.GetFirst
                                 ();
                AssertEquals("function 9", f.GetName());
            }
            finally
            {
                NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(d);
            }
        }
示例#7
0
文件: Tutorial.cs 项目: ekicyou/pasta
        /// <summary>
        /// How to retrieve objects using Criteria queries using object
        /// </summary>
        public void Step5()
        {
            ODB odb = null;

            try {
                // Open the database
                odb = ODBFactory.Open(ODB_NAME);
                // retrieve the volley ball sport object
                IQuery query      = new CriteriaQuery(typeof(Sport), Where.Equal("name", "volley-ball"));
                Sport  volleyBall = odb.GetObjects <Sport>(query).GetFirst();

                // Now build a query to get all players that play volley ball, using
                // the volley ball object
                query = new CriteriaQuery(Where.Equal("favoriteSport", volleyBall));

                Objects <Player> players = odb.GetObjects <Player>(query);

                Console.WriteLine("\nStep 5: Players of Voller-ball");

                int i = 1;
                // display each object
                while (players.HasNext())
                {
                    Console.WriteLine((i++) + "\t: " + players.Next());
                }
            } finally {
                if (odb != null)
                {
                    // Close the database
                    odb.Close();
                }
            }
        }
示例#8
0
        public virtual void TestCriteriaQueryQueryWithValueInList2()
        {
            string baseName = GetBaseName();

            SetUp(baseName);
            NeoDatis.Odb.ODB odb = Open(baseName);
            Profile          p0  = new Profile("profile0"
                                               );

            p0.AddFunction(new Function("f1"));
            p0.AddFunction(new Function("f2"));
            Profile p1 = new Profile("profile1"
                                     );

            p0.AddFunction(new Function("f12"));
            p0.AddFunction(new Function("f22"));
            User user = new User("The user"
                                 , "themail", p0);
            User user2 = new User("The user2"
                                  , "themail2", p1);

            odb.Store(user);
            odb.Store(user2);
            odb.Close();
            odb = Open(baseName);
            Function f2bis = (Function)
                             odb.GetObjects <Function>(new CriteriaQuery(Where.Equal("name", "f2"))).GetFirst();
            CriteriaQuery query = odb.CriteriaQuery(typeof(Profile), Where.Contain("functions", f2bis));

            NeoDatis.Odb.Objects <Profile> l = odb.GetObjects <Profile>(query);
            AssertEquals(1, l.Count);
            p1 = l.GetFirst();
            AssertEquals("profile0", p1.GetName());
            odb.Close();
        }
示例#9
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test5()
 {
     try
     {
         DeleteBase(FileName);
         NeoDatis.Odb.ODB         odb  = Open(FileName);
         System.Collections.IList list = new System.Collections.ArrayList();
         for (int i = 0; i < 15; i++)
         {
             Function function = new Function
                                     ("function " + i);
             odb.Store(function);
             list.Add(function);
         }
         odb.Close();
         NeoDatis.Odb.OdbConfiguration.SetMaxNumberOfObjectInCache(15);
         odb = Open(FileName);
         NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery(Where
                                                                  .Or().Add(Where.Like("name", "%9")).Add(Where
                                                                                                          .Like("name", "%8")));
         NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(query, false);
         AssertEquals(2, l.Count);
         l.Next();
         odb.Store(l.Next());
         odb.Close();
         odb = Open(FileName);
         AssertEquals(15, odb.Count(new CriteriaQuery()));
         odb.Close();
     }
     finally
     {
         NeoDatis.Odb.OdbConfiguration.SetMaxNumberOfObjectInCache(300000);
     }
 }
示例#10
0
        public virtual void Test1()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            System.Collections.Generic.IList <Profile> profiles = new
                                                                  System.Collections.Generic.List <Profile>();
            profiles.Add(new Profile("p1", new Function
                                         ("f1")));
            profiles.Add(new Profile("p2", new Function
                                         ("f2")));
            ClassB cb = new ClassB
                            ("name", profiles);

            odb.Store(cb);
            odb.Close();
            odb = Open(baseName);
            // this object is not known y NeoDatis so the query will not return anything
            Profile       p     = new Profile("p1", (System.Collections.Generic.IList <Function>)null);
            CriteriaQuery query = odb.CriteriaQuery(typeof(
                                                        ClassB), Where
                                                    .Contain("profiles", p));

            NeoDatis.Odb.Objects <ClassB> l = odb.GetObjects <ClassB>(
                query);
            odb.Close();
            AssertEquals(0, l.Count);
        }
示例#11
0
        public virtual void TestCriteriaQueryQueryWithValueInList6()
        {
            string baseName = GetBaseName();

            SetUp(baseName);
            NeoDatis.Odb.ODB odb     = Open(baseName);
            IList <string>   strings = new List
                                       <string>();
            ClassWithListOfString c = new ClassWithListOfString
                                          ("name", strings);

            c.GetStrings().Add("s1");
            c.GetStrings().Add(null);
            c.GetStrings().Add("s3");
            IList <string> strings2 = new List
                                      <string>();
            ClassWithListOfString c2 = new ClassWithListOfString
                                           ("name", null);

            odb.Store(c);
            odb.Store(c2);
            odb.Close();
            odb = Open(baseName);
            CriteriaQuery query = new CriteriaQuery
                                      (typeof(ClassWithListOfString), Where
                                      .Contain("strings", "s4"));

            NeoDatis.Odb.Objects <ClassWithListOfString> l =
                odb.GetObjects <ClassWithListOfString>(query);
            odb.Close();
            AssertEquals(0, l.Count);
        }
示例#12
0
        public virtual void TestReuse()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            System.Collections.Generic.IList <Profile> profiles = new
                                                                  System.Collections.Generic.List <Profile>();
            profiles.Add(new Profile("p1", new Function
                                         ("f1")));
            profiles.Add(new Profile("p2", new Function
                                         ("f2")));
            ClassB cb = new ClassB
                            ("name", profiles);

            odb.Store(cb);
            odb.Close();
            odb = Open(baseName);
            Profile       p     = (Profile)odb.GetObjects <Profile>().GetFirst();
            CriteriaQuery query = odb.CriteriaQuery(typeof(
                                                        ClassB), Where.Equal("profiles", p));
            EqualCriterion ec = (EqualCriterion     )query.GetCriteria();

            try
            {
                NeoDatis.Odb.Objects <ClassB> l = odb.GetObjects <ClassB>(
                    query);
            }
            catch (System.Exception e)
            {
                AssertTrue(NeoDatis.Tool.Wrappers.OdbString.ExceptionToString(e, true).IndexOf("1063"
                                                                                               ) != -1);
            }
            odb.Close();
        }
示例#13
0
文件: Tutorial.cs 项目: ekicyou/pasta
        /// <summary>
        /// Using Indexes
        /// </summary>
        public void Step11()
        {
            // Open the database
            ODB odb = null;

            try {
                odb = ODBFactory.Open(ODB_NAME);

                String[] fieldNames = { "name" };
                odb.GetClassRepresentation(typeof(Sport)).AddUniqueIndexOn("sport-index", fieldNames, true);
                odb.Close();

                odb = ODBFactory.Open(ODB_NAME);
                IQuery query = new CriteriaQuery(typeof(Sport), Where.Equal("name", "volley-ball"));

                Objects <Sport> sports = odb.GetObjects <Sport>(query);

                Console.WriteLine("\nStep 11 : Using index");

                int i = 1;
                // display each object
                while (sports.HasNext())
                {
                    Console.WriteLine((i++) + "\t: " + sports.Next());
                }
            } finally {
                if (odb != null)
                {
                    // Close the database
                    odb.Close();
                }
            }
        }
示例#14
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test1()
        {
            NeoDatis.Odb.ODB odb = Open(FileName);
            NeoDatis.Odb.Core.Query.IQuery  query = new CriteriaQuery(Where.Equal("name", "function 10"));
            NeoDatis.Odb.Objects <Function> l     = odb.GetObjects <Function>(query);
            int size = l.Count;

            AssertFalse(l.Count == 0);
            Function f = (Function)l.GetFirst
                             ();

            NeoDatis.Odb.OID id = odb.GetObjectId(f);
            AssertEquals("function 10", f.GetName());
            string newName = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs().ToString();

            f.SetName(newName);
            odb.Store(f);
            odb.Close();
            odb   = Open(FileName);
            l     = odb.GetObjects <Function>(query);
            query = new CriteriaQuery(Where.Equal("name", newName));
            AssertTrue(size == l.Count + 1);
            l = odb.GetObjects <Function>(query);
            AssertFalse(l.Count == 0);
            AssertEquals(1, l.Count);
            AssertEquals(id, odb.GetObjectId(l.GetFirst()));
            odb.Close();
        }
示例#15
0
文件: Tutorial.cs 项目: ekicyou/pasta
        /// <summary>
        /// How to retrieve objects using Criteria queries
        /// </summary>
        public void Step3()
        {
            ODB odb = null;

            try {
                // Open the database
                odb = ODBFactory.Open(ODB_NAME);
                IQuery           query   = new CriteriaQuery(Where.Equal("name", "olivier"));
                Objects <Player> players = odb.GetObjects <Player>(query);

                Console.WriteLine("\nStep 3 : Players with name olivier");

                int i = 1;
                // display each object
                while (players.HasNext())
                {
                    Console.WriteLine((i++) + "\t: " + players.Next());
                }
            } finally {
                if (odb != null)
                {
                    // Close the database
                    odb.Close();
                }
            }
        }
示例#16
0
文件: Tutorial.cs 项目: ekicyou/pasta
        /**
         * How to retrieve objects using Criteria queries with Not
         *
         */
        /// <summary>
        /// How to retrieve objects using Criteria queries using object
        /// </summary>
        public void Step7()
        {
            ODB odb = null;

            try {
                // Open the database
                odb = ODBFactory.Open(ODB_NAME);
                IQuery query = new CriteriaQuery(typeof(Player), Where.Not(Where.Equal("favoriteSport.name", "volley-ball")));

                Objects <Player> players = odb.GetObjects <Player>(query);

                Console.WriteLine("\nStep 7 : Players that don't play Volley-ball");

                int i = 1;
                // display each object
                while (players.HasNext())
                {
                    Console.WriteLine((i++) + "\t: " + players.Next());
                }
            } finally {
                if (odb != null)
                {
                    // Close the database
                    odb.Close();
                }
            }
        }
示例#17
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestGetLimitedResult4()
        {
            string baseName = GetBaseName();
            int    size     = 1000;

            NeoDatis.Odb.ODB odb = Open(baseName);
            for (int i = 0; i < size; i++)
            {
                if (i < size / 2)
                {
                    odb.Store(new Function("function " + i));
                }
                else
                {
                    odb.Store(new Function("FUNCTION " + i));
                }
            }
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Core.Query.IQuery  q  = new CriteriaQuery(Where.Like("name", "FUNCTION%"));
            NeoDatis.Odb.Objects <Function> os = odb.GetObjects <Function>(q, true, 10, 20);
            AssertEquals(10, os.Count);
            for (int i = size / 2 + 10; i < size / 2 + 20; i++)
            {
                Function f = (Function)os.Next
                                 ();
                AssertEquals("FUNCTION " + i, f.GetName());
            }
            odb.Close();
            DeleteBase(baseName);
        }
示例#18
0
文件: Tutorial.cs 项目: ekicyou/pasta
        /// <summary>
        /// How to retrieve objects using Criteria queries traversing relations
        /// </summary>
        public void Step4()
        {
            ODB odb = null;

            try {
                // Open the database
                odb = ODBFactory.Open(ODB_NAME);
                // Let's insert a tennis player
                Player agassi = new Player("Andr\u00E9 Agassi", new DateTime(), new Sport("Tennis"));
                odb.Store(agassi);

                IQuery query = new CriteriaQuery(typeof(Player), Where.Equal("favoriteSport.name", "volley-ball"));

                Objects <Player> players = odb.GetObjects <Player>(query);

                Console.WriteLine("\nStep 4 : Players of Voller-ball");

                int i = 1;
                // display each object
                while (players.HasNext())
                {
                    Console.WriteLine((i++) + "\t: " + players.Next());
                }
            } finally {
                if (odb != null)
                {
                    // Close the database
                    odb.Close();
                }
            }
        }
示例#19
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestCriteriaQueryQueryWithValueInList4()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            System.Collections.Generic.IList <string> strings = new System.Collections.Generic.List
                                                                <string>();
            ClassWithListOfString c = new ClassWithListOfString
                                          ("name", strings);

            c.GetStrings().Add("s1");
            c.GetStrings().Add("s2");
            c.GetStrings().Add("s3");
            System.Collections.Generic.IList <string> strings2 = new System.Collections.Generic.List
                                                                 <string>();
            ClassWithListOfString c2 = new ClassWithListOfString
                                           ("name", strings2);

            c2.GetStrings().Add("s1");
            c2.GetStrings().Add("s2");
            c2.GetStrings().Add("s3");
            odb.Store(c);
            odb.Store(c2);
            odb.Close();
            odb = Open(baseName);
            CriteriaQuery query = new CriteriaQuery(Where.Contain("strings", "s2222"));

            NeoDatis.Odb.Objects <ClassWithListOfString> l = odb.GetObjects <ClassWithListOfString>(query);
            AssertEquals(0, l.Count);
            odb.Close();
        }
示例#20
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test1()
        {
            NeoDatis.Odb.ODB odb   = Open(BaseName);
            CriteriaQuery    query = new CriteriaQuery(Where.Equal("profile.name", "profile2"));

            NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(query);
            AssertEquals(1, l.Count);
            odb.Close();
        }
示例#21
0
        public virtual void TestSodaWithBoolean()
        {
            NeoDatis.Odb.ODB odb   = Open(BaseName);
            CriteriaQuery    query = new CriteriaQuery(Where.Equal("boolean1", true));

            NeoDatis.Odb.Objects <TestClass> l = odb.GetObjects <TestClass>(query);
            AssertTrue(l.Count > 1);
            query = new CriteriaQuery(Where.Equal("boolean1", true));
            l     = odb.GetObjects <TestClass>(query);
            AssertTrue(l.Count > 1);
            odb.Close();
        }
示例#22
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test2()
        {
            NeoDatis.Odb.ODB odb = Open(BaseName);
            CriteriaQuery    aq  = new CriteriaQuery(Where.Not(Where.Equal("string1", "test class 2")));

            NeoDatis.Odb.Objects <TestClass> l = odb.GetObjects <TestClass>(aq, true, -1, -1);
            AssertEquals(49, l.Count);
            TestClass testClass = l.GetFirst();

            AssertEquals("test class 0", testClass.GetString1());
            odb.Close();
        }
示例#23
0
文件: TestMap.cs 项目: ekicyou/pasta
        public virtual void Test2()
        {
            NeoDatis.Odb.ODB odb = Open("map.neodatis");
            NeoDatis.Odb.Objects <Dictionnary> l = odb.GetObjects <Dictionnary>();
            CriteriaQuery aq = new CriteriaQuery(typeof(Dictionnary), Where.Equal("name", "test2"));

            l = odb.GetObjects <Dictionnary>(aq);
            Dictionnary dictionnary = l.GetFirst();

            AssertEquals("function2", ((Function)dictionnary.Get("f2")).GetName());
            odb.Close();
        }
示例#24
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test1()
        {
            NeoDatis.Odb.ODB odb = Open(BaseName);
            CriteriaQuery    aq  = new CriteriaQuery(Where.Or().Add(Where.Equal("string1", "test class 1")).Add(Where.Equal("string1", "test class 3")));

            aq.OrderByAsc("string1");
            NeoDatis.Odb.Objects <TestClass> l = odb.GetObjects <TestClass>(aq, true, -1, -1);
            AssertEquals(2, l.Count);
            TestClass testClass = l.GetFirst();

            AssertEquals("test class 1", testClass.GetString1());
            odb.Close();
        }
示例#25
0
        public IActionResult getCriteria()
        {
            try
            {
                var query    = new CriteriaQuery();
                var criteria = _queryProcessor.Process(query);

                return(new OkObjectResult(criteria));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
示例#26
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test3()
        {
            NeoDatis.Odb.ODB odb = Open(BaseName);
            CriteriaQuery    aq  = new CriteriaQuery(Where.Not(Where.Or().Add(Where
                                                                              .Equal("string1", "test class 0")).Add(Where.Equal
                                                                                                                         ("bigDecimal1", new System.Decimal(5)))));

            NeoDatis.Odb.Objects <TestClass> l = odb.GetObjects <TestClass>(aq, true, -1, -1);
            AssertEquals(48, l.Count);
            TestClass testClass = (TestClass
                                   )l.GetFirst();

            AssertEquals("test class 1", testClass.GetString1());
            odb.Close();
        }
示例#27
0
        public virtual void Test51()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            odb.Store(new Function("Not Null"));
            odb.Store(new Function(null));
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Core.Query.IQuery q = new CriteriaQuery(Where.IsNotNull("name"));
            // q.orderByAsc("name");
            NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(q, true, 0, 10);
            odb.Close();
            AssertEquals(1, objects.Count);
        }
示例#28
0
        public virtual void TestLike2()
        {
            string baseName = GetBaseName();

            SetUp(baseName);
            NeoDatis.Odb.ODB odb = Open(baseName);
            CriteriaQuery    aq  = new CriteriaQuery
                                       (typeof(Function), Where
                                       .Like("name", "FuNc%"));

            aq.OrderByDesc("name");
            NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(aq, true, -1, -1);
            AssertEquals(0, l.Count);
            odb.Close();
        }
示例#29
0
        public virtual void TestSodaWithDouble()
        {
            NeoDatis.Odb.ODB odb   = Open(BaseName);
            CriteriaQuery    query = new CriteriaQuery(Where.Equal("double1", 190.99));

            NeoDatis.Odb.Objects <TestClass> l = odb.GetObjects <TestClass>(query);
            AssertEquals(1, l.Count);
            query = new CriteriaQuery(Where.Gt("double1", (double)189));
            l     = odb.GetObjects <TestClass>(query);
            AssertTrue(l.Count >= 1);
            query = new CriteriaQuery(Where.Lt("double1", (double)191));
            l     = odb.GetObjects <TestClass>(query);
            AssertTrue(l.Count >= 1);
            odb.Close();
        }
示例#30
0
        public virtual void TestInsert()
        {
            DeleteBase(NewbieOdb);
            odb = Open(NewbieOdb);
            Driver marcelo = new Driver
                                 ("marcelo");
            Car car = new Car("car1",
                              4, "ranger", marcelo);
            Car car1 = new Car("car2"
                               , 2, "porche");
            Car car2 = new Car("car3"
                               , 2, "fusca");
            Car car3 = new Car("car4"
                               , 4, "opala");
            Car car4 = new Car("car5"
                               , 4, "vectra", marcelo);

            try
            {
                // open is called on NewbieTest
                // insert 5 car's
                odb.Store(car);
                odb.Store(car1);
                odb.Store(car2);
                odb.Store(car3);
                odb.Store(car4);
                // find for all car objects
                NeoDatis.Odb.Objects <Car> cars = odb.GetObjects <Car>();
                AssertEquals("The objects weren't added correctly", 5, cars.Count);
                // find for a specific car object
                CriteriaQuery query = new CriteriaQuery(typeof(Car), Where.Equal("name", "car1"));
                cars = odb.GetObjects <Car>(query);
                AssertEquals("The objects couldn't be found correctly", 1, cars.Count);
                // find for a specific composition
                query = new CriteriaQuery(typeof(Car), Where.Equal("driver.name", "marcelo"));
                cars  = odb.GetObjects <Car>(query);
                AssertEquals("The objects couldn't be found correctly", 2, cars.Count);
                odb.Commit();
                odb.Close();
                DeleteBase(NewbieOdb);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e);
            }
        }