示例#1
0
        public void GetListTest()
        {
            using (TestSqlDataSource testDataSource = new TestSqlDataSource("default"))
            {
                testDataSource.Open();

                using (SoodaTransaction tran = new SoodaTransaction())
                {
                    tran.RegisterDataSource(testDataSource);

                    Contact mary = Contact.Load(1);
                    //mary.Name = "Ala ma kota";

                    Contact ed = Contact.Load(2);
                    ed.PrimaryGroup = null;

                    ContactList list = Contact.GetList(tran, new SoodaWhereClause("PrimaryGroup.Manager.Name = 'Mary Manager'"), SoodaSnapshotOptions.Default);
                    Console.WriteLine("Len: {0}", list.Count);

                    SoodaObjectMultiFieldComparer comparer = new SoodaObjectMultiFieldComparer();

                    comparer.AddField(new string[] { "PrimaryGroup", "Name" }, SortOrder.Ascending);
                    comparer.AddField("LastSalary", SortOrder.Ascending);
                    comparer.AddField("Name", SortOrder.Descending);

                    foreach (Contact c in list.Sort(comparer).Filter(new SoodaObjectFilter(predicate1)))
                    {
                        Console.WriteLine("Member: {0} - {2} - {1}", c.Evaluate("PrimaryGroup.Name"), c.Name, c.LastSalary);
                    }
                    tran.Commit();
                }
            }
        }
示例#2
0
        public void GetListTest()
        {
            using (TestSqlDataSource testDataSource = new TestSqlDataSource("default"))
            {
                testDataSource.Open();

                using (SoodaTransaction tran = new SoodaTransaction())
                {
                    tran.RegisterDataSource(testDataSource);

                    Contact mary = Contact.Load(1);
                    //mary.Name = "Ala ma kota";

                    Contact ed = Contact.Load(2);
                    ed.PrimaryGroup = null;

                    ContactList list = Contact.GetList(tran, new SoodaWhereClause("PrimaryGroup.Manager.Name = 'Mary Manager'"), SoodaSnapshotOptions.Default);
                    Console.WriteLine("Len: {0}", list.Count);

                    SoodaObjectMultiFieldComparer comparer = new SoodaObjectMultiFieldComparer();

                    comparer.AddField(new string[] { "PrimaryGroup", "Name" }, SortOrder.Ascending);
                    comparer.AddField("LastSalary", SortOrder.Ascending);
                    comparer.AddField("Name", SortOrder.Descending);

                    foreach (Contact c in list.Sort(comparer).Filter(new SoodaObjectFilter(predicate1)))
                    {
                        Console.WriteLine("Member: {0} - {2} - {1}", c.Evaluate("PrimaryGroup.Name"), c.Name, c.LastSalary);
                    }
                    tran.Commit();
                }
            }
        }