Beispiel #1
0
        public void SelectAllColumnsFromOneTableOrderedByTwoFields()
        {
            SqlBuilder builder = SqlBuilder.Select(2000)
                                 .From("Account")
                                 .AllColumns(false)
                                 .OrderBy("City", OrderByDirections.Desc).OrderBy("Name", OrderByDirections.Asc)
                                 .Builder;

            Console.WriteLine(builder.ToSql());
            Guid        g      = StopWatch.Start();
            ResultTable result = builder.Execute(120);

            Console.WriteLine("ResulTable with {0} rows executed in {1}ms", result.Count, StopWatch.Stop(g, StopWatch.WatchTypes.Milliseconds));
            foreach (dynamic row in result.Take(10))
            {
                Console.WriteLine("{0} {1} - Ordered by City DESC, Name ASC", row.Name, row.City);
            }
        }
Beispiel #2
0
        public void ExecuteDeep()
        {
            ResultTable result = ExecuteDeepInternal();

            Console.WriteLine("The result has {0} Account rows", result.Count);
            Console.WriteLine("These accounts has a total of {0} Contact rows", result.SelectMany(x => x.Column <ResultTable>("Contacts")).Count());
            Console.WriteLine("These contacts has a total of {0} Activity rows", result.SelectMany(x => x.Column <ResultTable>("Contacts")).SelectMany(y => y.Column <ResultTable>("Activities")).Count());
            Console.WriteLine("These contacts has a total of {0} Campaign Activity rows", result.SelectMany(x => x.Column <ResultTable>("Contacts")).SelectMany(y => y.Column <ResultTable>("CampaignActivityList")).Count());
            foreach (dynamic row in result.Take(50))
            {
                ResultTable contacts = row.Contacts;
                Console.WriteLine("The account {0} has {1} Contacts", row.Name, contacts.Count);
                Console.WriteLine("The account {0} has a total of {1} Activities", row.Name, contacts.SelectMany(x => x.Column <ResultTable>("Activities")).Count());
            }

            Console.Write("Executing a second time with results in cahce:");
            result = ExecuteDeepInternal();
        }