コード例 #1
0
        public void Test()
        {
            var dynamicQuery = BuildDynamicQuery();
            var whereClause  = BuilderWhereClause(dynamicQuery);
            var orderClause  = BuildOrderClause(dynamicQuery);

            // Get data ready
            var context = ServiceProvider.GetRequiredService <Context>();

            context.TestingDto.Add(new Model.TestingDto
            {
                Id          = Guid.NewGuid().ToString("N"),
                TestAddress = "chengdu lnk",
                Disabled    = false,
                Amout       = 11,
                Price       = 110,
                Drink       = "coffee",
                Count       = 1,
                Total       = 100,
                Url         = "Http://www.feiniubus.com",
                Extras      = new HashSet <Model.TestingDto.Extra>()
                {
                    new Model.TestingDto.Extra
                    {
                        Guest = "Andy"
                    }
                }
            });
            context.SaveChanges();

            //testing
            var entityType = typeof(Model.TestingDto);
            var converter  = new QueryConverter(entityType, dynamicQuery, true);
            var model      = converter.Converter();
            var entities   = AutoQueryAsync(context.TestingDto.AsQueryable(), model, true);

            //sql testing
            var sb = new StringBuilder();

            sb.AppendLine("SELECT * FROM TestingDto WHERE");
            sb.AppendLine(whereClause.Item1);
            sb.AppendLine("ORDER BY");
            sb.AppendLine(orderClause);
            sb.AppendLine(";");
            string sql = sb.ToString();


            Assert.True(entities?.Rows?.Count() > 0);
        }
コード例 #2
0
        public void TestChargeHistory()
        {
            var query = new Model.ChargeHostory[]
            {
                new Model.ChargeHostory(),
                new Model.ChargeHostory(),
            }.AsQueryable();

            var builder = new DynamicQueryBuilder(true);

            builder.Take(20).Skip(10).ParamGroupBuilder.ParamBuilder.Equal("charge_id", 1);

            var converter = new QueryConverter(typeof(Model.ChargeHostory), builder.Build(), true);
            var model     = converter.Converter();
        }