Ejemplo n.º 1
0
        public async Task test()
        {
            var xx6 = "";

            var res6 = await Conn
                       .Selecter <Agent>()
                       .Where(it => it.CreatedOn >= WhereTest.CreatedOn)
                       .PagingListAsync <AgentVM>(1, 10);

            var tuple6 = (XDebug.SQL, XDebug.Parameters);

            var resR6 = await Conn
                        .Selecter <Agent>()
                        .Where(it => WhereTest.CreatedOn <= it.CreatedOn)
                        .PagingListAsync <AgentVM>(1, 10);

            Assert.True(res6.TotalCount == resR6.TotalCount);
            Assert.True(res6.TotalCount == 28619);

            var tupleR6 = (XDebug.SQL, XDebug.Parameters);


            /*************************************************************************************************************************/

            var xx13 = "";

            var option13 = new AgentQueryOption();
            var res13    = await Conn
                           .Selecter <Agent>()
                           .Where(option13.GetCondition())
                           .PagingListAsync <AgentVM>(option13);

            Assert.True(res13.TotalCount == 28620);
            Assert.True(res13.Data.Count == 10);

            var tuple13 = (XDebug.SQL, XDebug.Parameters, XDebug.SqlWithParams);

            /*************************************************************************************************************************/
        }
Ejemplo n.º 2
0
        public async Task WhereObjQueryOptionTest()
        {
            /*************************************************************************************************************************/

            var xx1 = "";

            // where object
            var res1 = await Conn.OpenDebug()
                       .Selecter <Agent>()
                       .Where(new
            {
                Id   = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"),
                Name = "樊士芹",
                xxx  = "xxx"
            })
                       .QueryListAsync();

            var tuple1 = (XDebug.SQL, XDebug.Parameters);

            /*************************************************************************************************************************/

            var xx2 = "";

            var option = new AgentQueryOption();

            option.Id   = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b");
            option.Name = "樊士芹";
            // where method
            var res2 = await Conn.OpenDebug()
                       .Selecter <Agent>()
                       .Where(option.GetCondition())
                       .QueryPagingListAsync(option);

            var tuple2 = (XDebug.SQL, XDebug.Parameters);

            /*************************************************************************************************************************/

            var xx3 = "";

            option.OrderBys = new List <OrderBy>
            {
                new OrderBy
                {
                    Field = "Name",
                    Desc  = true
                }
            };
            // where method -- option orderby
            var res3 = await Conn.OpenDebug()
                       .Selecter <Agent>()
                       .Where(option.GetCondition())
                       .QueryPagingListAsync <AgentVM>(option);

            var tuple3 = (XDebug.SQL, XDebug.Parameters);

            /*************************************************************************************************************************/

            var xx4 = "";

            // where object --> no where
            var res4 = await Conn.OpenDebug()
                       .Selecter <Agent>()
                       .Where(new
            {
                //Id = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"),
                //Name = "樊士芹",
                xxx = "xxx"
            })
                       .QueryListAsync();

            var tuple4 = (XDebug.SQL, XDebug.Parameters);

            // no where --> and or
            var res41 = await Conn.OpenDebug()
                        .Selecter <Agent>()
                        .Where(new
            {
                //Id = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"),
                //Name = "樊士芹",
                xxx = "xxx"
            })
                        .And(it => it.Id == Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"))
                        .Or(it => it.AgentLevel == AgentLevel.DistiAgent)
                        .QueryListAsync();

            var tuple41 = (XDebug.SQL, XDebug.Parameters);

            // no where --> or and
            var res42 = await Conn.OpenDebug()
                        .Selecter <Agent>()
                        .Where(new
            {
                //Id = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"),
                //Name = "樊士芹",
                xxx = "xxx"
            })
                        .Or(it => it.AgentLevel == AgentLevel.Customer)
                        .And(it => it.Name == "金月琴")
                        .QueryListAsync();

            var tuple42 = (XDebug.SQL, XDebug.Parameters);

            /*************************************************************************************************************************/

            var xx5 = "";

            var option2 = new ProductQueryOption
            {
                VipProduct = null     // true fals null
            };
            // where method -- option orderby
            var res5 = await Conn.OpenDebug()
                       .Selecter <Product>()
                       .Where(option2.GetCondition())
                       .QueryPagingListAsync(option2);

            var tuple5 = (XDebug.SQL, XDebug.Parameters);


            /*************************************************************************************************************************/

            var option6 = new AgentQueryOption();

            option6.AgentLevel = AgentLevel.DistiAgent;

            var xx6 = "";

            var res6 = await Conn.OpenDebug()
                       .Joiner <Agent, AgentInventoryRecord>(out var agent6, out var record6)
                       .From(() => agent6)
                       .InnerJoin(() => record6)
                       .On(() => agent6.Id == record6.AgentId)
                       .Where(() => agent6.AgentLevel == AgentLevel.DistiAgent)
                       .QueryPagingListAsync <Agent>(option6);

            Assert.True(res6.TotalCount == 574);

            var tuple6 = (XDebug.SQL, XDebug.Parameters);

            /*************************************************************************************************************************/

            var xx7 = "";

            // where method -- option orderby
            var res7 = await Conn.OpenDebug()
                       .Selecter <Agent>()
                       //.Where(option.GetCondition())
                       .Where(it => it.Name == "樊士芹")
                       .QueryPagingListAsync(option, agent => new AgentVM
            {
                XXXX = agent.Name,
                YYYY = agent.PathId
            });

            var tuple7 = (XDebug.SQL, XDebug.Parameters);

            /*************************************************************************************************************************/

            var xx = "";
        }
Ejemplo n.º 3
0
        public async Task test()
        {
            /*************************************************************************************************************************/

            var xx1 = "";

            // where object
            var res1 = await Conn
                       .Selecter <Agent>()
                       .Where(new
            {
                Id   = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"),
                Name = "樊士芹",
                xxx  = "xxx"
            })
                       .ListAsync();

            Assert.True(res1.Count == 1);
            Assert.True(res1.First().Name == "樊士芹");

            var tuple1 = (XDebug.SQL, XDebug.Parameters);

            /*************************************************************************************************************************/

            var xx2 = "";

            var option = new AgentQueryOption();

            option.Id   = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b");
            option.Name = "樊士芹";
            // where method
            var res2 = await Conn
                       .Selecter <Agent>()
                       .Where(option.GetCondition())
                       .PagingListAsync(option);

            Assert.True(res2.TotalCount == 1);

            var tuple2 = (XDebug.SQL, XDebug.Parameters);

            /*************************************************************************************************************************/

            var xx3 = "";

            option.OrderBys = new List <OrderBy>
            {
                new OrderBy
                {
                    Field = "Name",
                    Desc  = true
                }
            };
            // where method -- option orderby
            var res3 = await Conn
                       .Selecter <Agent>()
                       .Where(option.GetCondition())
                       .PagingListAsync <AgentVM>(option);

            Assert.True(res3.TotalCount == 1);

            var tuple3 = (XDebug.SQL, XDebug.Parameters);

            /*************************************************************************************************************************/

            var xx4 = "";

            // where object --> no where
            var res4 = await Conn
                       .Selecter <Agent>()
                       .Where(new
            {
                //Id = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"),
                //Name = "樊士芹",
                xxx = "xxx"
            })
                       .ListAsync();

            Assert.True(res4.Count == 28620);

            var tuple4 = (XDebug.SQL, XDebug.Parameters);

            // no where --> and or
            var res41 = await Conn
                        .Selecter <Agent>()
                        .Where(new
            {
                //Id = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"),
                //Name = "樊士芹",
                xxx = "xxx"
            })
                        .And(it => it.Id == Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"))
                        .Or(it => it.AgentLevel == AgentLevel.DistiAgent)
                        .ListAsync();

            Assert.True(res41.Count == 556);

            var tuple41 = (XDebug.SQL, XDebug.Parameters);

            // no where --> or and
            var res42 = await Conn
                        .Selecter <Agent>()
                        .Where(new
            {
                //Id = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"),
                //Name = "樊士芹",
                xxx = "xxx"
            })
                        .Or(it => it.AgentLevel == AgentLevel.Customer)
                        .And(it => it.Name == "金月琴")
                        .ListAsync();

            Assert.True(res42.Count == 1);

            var tuple42 = (XDebug.SQL, XDebug.Parameters);

            /*************************************************************************************************************************/

            var xx5 = "";

            var option2 = new ProductQueryOption
            {
                VipProduct = null     // true fals null
            };
            // where method -- option orderby
            var res5 = await Conn
                       .Selecter <Product>()
                       .Where(option2.GetCondition())
                       .PagingListAsync(option2);

            Assert.True(res5.Data.Count == 4);

            option2.VipProduct = false;
            var res51 = await Conn
                        .Selecter <Product>()
                        .Where(option2.GetCondition())
                        .PagingListAsync(option2);

            Assert.True(res51.Data.Count == 4);

            option2.VipProduct = true;
            var res52 = await Conn
                        .Selecter <Product>()
                        .Where(option2.GetCondition())
                        .PagingListAsync(option2);

            Assert.True(res52.Data.Count == 0);

            var tuple5 = (XDebug.SQL, XDebug.Parameters);
        }
Ejemplo n.º 4
0
        public async Task WhereObjQueryOptionTest()
        {
            var xx1 = "";

            // where object
            var res1 = await Conn.OpenDebug()
                       .Selecter <Agent>()
                       .Where(new
            {
                Id   = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"),
                Name = "樊士芹",
                xxx  = "xxx"
            })
                       .QueryListAsync();

            var tuple1 = (XDebug.SQL, XDebug.Parameters);

            var xx2 = "";


            var option = new AgentQueryOption();

            option.Id   = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b");
            option.Name = "樊士芹";
            // where method
            var res2 = await Conn.OpenDebug()
                       .Selecter <Agent>()
                       .Where(option.GetCondition())
                       .QueryPagingListAsync(option);

            var tuple2 = (XDebug.SQL, XDebug.Parameters);

            var xx3 = "";

            option.OrderBys = new List <OrderBy>
            {
                new OrderBy
                {
                    Field = "Name",
                    Desc  = true
                }
            };
            // where method -- option orderby
            var res3 = await Conn.OpenDebug()
                       .Selecter <Agent>()
                       .Where(option.GetCondition())
                       .QueryPagingListAsync <AgentVM>(option);

            var tuple3 = (XDebug.SQL, XDebug.Parameters);

            var xx4 = "";

            // where object --> no where
            var res4 = await Conn.OpenDebug()
                       .Selecter <Agent>()
                       .Where(new
            {
                //Id = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"),
                //Name = "樊士芹",
                xxx = "xxx"
            })
                       .QueryListAsync();

            var tuple4 = (XDebug.SQL, XDebug.Parameters);

            // no where --> and or
            var res41 = await Conn.OpenDebug()
                        .Selecter <Agent>()
                        .Where(new
            {
                //Id = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"),
                //Name = "樊士芹",
                xxx = "xxx"
            })
                        .And(it => it.Id == Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"))
                        .Or(it => it.AgentLevel == AgentLevel.DistiAgent)
                        .QueryListAsync();

            var tuple41 = (XDebug.SQL, XDebug.Parameters);

            // no where --> or and
            var res42 = await Conn.OpenDebug()
                        .Selecter <Agent>()
                        .Where(new
            {
                //Id = Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"),
                //Name = "樊士芹",
                xxx = "xxx"
            })
                        .Or(it => it.AgentLevel == AgentLevel.Customer)
                        .And(it => it.Name == "金月琴")
                        .QueryListAsync();

            var tuple42 = (XDebug.SQL, XDebug.Parameters);

            var xx5 = "";

            var option2 = new ProductQueryOption
            {
                VipProduct = null     // true fals null
            };
            // where method -- option orderby
            var res5 = await Conn.OpenDebug()
                       .Selecter <Product>()
                       .Where(option2.GetCondition())
                       .QueryPagingListAsync(option2);

            var tuple5 = (XDebug.SQL, XDebug.Parameters);


            var xx = "";
        }