예제 #1
0
        private void Example1()
        {
            IQueryBuilder builder = null;

            var query = builder
                        // Return the first 10 customers that have 'fred' as a rep using the 'customer_rep' index
                        .Begin()
                        .Assign("count").Literal(0)
                        .BeginFor("customer")
                        .OrderBy("customerId").Ascending()
                        .FromTable("customers").UsingIndex("customer_rep")
                        .Function(q => new[] { new Tuple <IColumnDefinition, CompareOperation, object>(q.Table["customers"].Column["rep_name"], CompareOperation.Equal, "fred") })
                        //.WhereColumns(new Tuple<string, CompareOperation, object>("rep_name", CompareOperation.Equal, "fred"))
                        //.WhereColumn("rep_name", CompareOperation.Equal).Literal("fred")
                        .If().Compare(CompareOperation.Equal).Variable("count").Literal(10).Break()
                        .Assign("count").Unary(UnaryOperator.Increment).Variable("count")
                        .BeginSelect()
                        .Field("customerId").Alias("id")
                        .Field("name").Alias("customerName")
                        .EndSelect()
                        .EndFor()
                        .End()

                        // Build the query
                        .Build();
        }