예제 #1
0
 static bool all(iSerializerSession sess)
 {
     foreach (var r in sess.Recordset <Record>().all())
     {
         Console.WriteLine("{0}", r);
     }
     return(false);
 }
예제 #2
0
        static bool search(iSerializerSession sess)
        {
            Console.Write("Text substring: ");
            string txt = Console.ReadLine();

            foreach (var r in sess.Recordset <Record>().where (r => r.text.Contains(txt)))
            {
                Console.WriteLine("{0}", r);
            }
            return(false);
        }
예제 #3
0
        void testPersons(iSerializerSession sess)
        {
            Recordset <Person> rs = sess.Recordset <Person>();

            Debug.WriteLine("Total count: {0}", rs.Count());

            Debug.WriteLine("Sorted by sex:");
            PrintPersons(rs.orderBy(p => p.sex));

            Debug.WriteLine("Males:");
            PrintPersons(rs.where (p => p.sex == Person.eSex.Male));

            Debug.WriteLine(@"Names containing ""Smith"":");
            PrintPersons(rs.where (p => p.name.Contains("Smith")));
        }
예제 #4
0
        // This one is the real.
        public Form1(SessionPool _pool)
        {
            InitializeComponent();

            pool = _pool;
            sess = pool.GetSession();
            rs   = sess.Recordset <EfsEntry>();

            EFS.Initialize(rs);

            fileIo = new FileIoThread();
            // fileIo = new TrivialFileIo();

            InitFoldersView();
        }
예제 #5
0
        static bool delete(iSerializerSession sess)
        {
            int?id = askId();

            if (!id.HasValue)
            {
                return(false);
            }
            var rs = sess.Recordset <Record>();

            if (!rs.seek(r => r.id == id.Value))
            {
                Console.WriteLine("Not found");
                return(false);
            }
            rs.cursor.delCurrent();
            return(true);
        }
예제 #6
0
        static bool update(iSerializerSession sess)
        {
            Record u = askRecord();

            if (null == u)
            {
                return(false);
            }
            var rs = sess.Recordset <Record>();

            if (!rs.seek(r => r.id == u.id))
            {
                Console.WriteLine("Not found");
                return(false);
            }
            rs.cursor.Update(u);
            return(true);
        }
예제 #7
0
        void testFilters(iSerializerSession sess)
        {
            Recordset <FiltersTest> rs = sess.Recordset <FiltersTest>();

            TestFilter[] filters = new TestFilter[]
            {
                // ft => ft.c2 == 8,
                // ft => ft.c2 >= 9,
                // ft => ft.c2 >= 2 && ft.c2 <= 3,
                // ft => 4 == ft.c2 && 5 == ft.c1 && ft.c3 >= 2 && ft.c3 <= 3,
                ft => Queries.greaterOrEqual(ft.c2, 9),
            };

            foreach (var f in filters)
            {
                var q = Queries.filter(rs.cursor.serializer, f);
                Debug.WriteLine("{0} => {1}", f.ToString(), rs.count(q));
            }
        }
예제 #8
0
        static bool read(iSerializerSession sess)
        {
            int?id = askId();

            if (!id.HasValue)
            {
                return(false);
            }
            var rec = sess.Recordset <Record>().where (r => r.id == id.Value).FirstOrDefault();

            if (null != rec)
            {
                Console.WriteLine("{0}", rec);
            }
            else
            {
                Console.WriteLine("Not found");
            }
            return(false);
        }
예제 #9
0
        static void RunTests(iSerializerSession sess)
        {
            var rs = sess.Recordset <Person>();

            using (var trans = sess.BeginTransaction())
            {
                Console.WriteLine("Total count: {0}", rs.Count());

                Console.WriteLine("Sorted by sex:");
                PrintPersons(rs.orderBy(p => p.sex));

                Console.WriteLine("Males:");
                PrintPersons(rs.where (p => Person.eSex.Male == p.sex));

                Console.WriteLine(@"Names containing ""Smith"":");
                PrintPersons(rs.where (p => p.name.Contains("Smith")));

                Console.WriteLine("Phone");
                PrintPersons(rs.where (p => Queries.Contains(p.phones, "+1 800 642 7676")));
                // The equivalent:
                // PrintPersons( rs.where( p => p.phones.Contains( "+1 800 642 7676" ) ) );
            }
        }