private DynamicQuery BuildDynamicQuery() { DynamicQueryBuilder builder = DynamicQueryBuilder.Create(true); var child1 = builder.ParamGroupBuilder.CreateChildAndGroup(); child1.ParamBuilder.Any("Extras", sub => { sub.ParamBuilder.Equal("Guest", "Andy"); }); var child2 = builder.ParamGroupBuilder.CreateChildAndGroup() .ParamBuilder .Contains("test_address", "chengdu") .EndsWith("test_address", "lnk") .Equal("Disabled", false) .GreaterThan("Amout", 10) .GreaterThanOrEqual("Price", 100) .In("Drink", "mileshake,coffee") .LessThan("Count", 10) .LessThanOrEqual("Total", 100) .StartsWith("Url", "Http://"); builder.OrderBy("test_address", ListSortDirection.Ascending) .Take(10); var dynamicQuery = builder.Build(); return(dynamicQuery); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.Run(async(context) => { DynamicQueryBuilder builder = DynamicQueryBuilder.Create(true); var child1 = builder.ParamGroupBuilder.CreateChildAndGroup(); child1.ParamBuilder.Any("Extra", sub => { sub.ParamBuilder.Equal("Guest", "Andy"); }); var child2 = builder.ParamGroupBuilder.CreateChildOrGroup() .ParamBuilder .Contains("Address", "chengdu") .EndsWith("Address", "lnk") .Equal("Disabled", false) .GreaterThan("Amout", 10) .GreaterThanOrEqual("Price", 100) .In("Drink", "mileshake,coffee") .LessThan("Count", 10) .LessThanOrEqual("Total", 100) .StartsWith("Url", "Http://"); builder.OrderBy("Amout", ListSortDirection.Ascending) .Select("Guest").Take(10).Skip(10); var dynamicQuery = builder.Build(); SqlBuilderSample(dynamicQuery, context.RequestServices.GetRequiredService <ISelectBuilder>()); }); }
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(); }