public void SqlBuffer_Batching_HasCorrectValue() { PageDescriptor page = this.locator.FindPage("../Commands/Batching/BatchedCommand.cssql", typeof(LocatorAccessor)); ProcFactory factory = this.engine.Proc(page, new ProcArgs(typeof(object), typeof(object))); IProcResult result = factory(null); ISqlSerializer <CommandData> serializer = result.Buffer as ISqlSerializer <CommandData>; IList <CommandData> batchedBySql = serializer.Serialize(new SqlOptions() { MaxSql = 1 }).ToList(); IList <CommandData> batchedByParams = serializer.Serialize(new SqlOptions() { MaxParameters = 2 }).ToList(); IList <CommandData> notBatched = serializer.Serialize(new SqlOptions()).ToList(); batchedBySql.ShouldNotBeNull(); batchedByParams.ShouldNotBeNull(); notBatched.ShouldNotBeNull(); batchedBySql.Count.ShouldBe(20); batchedByParams.Count.ShouldBe(10); notBatched.Count.ShouldBe(1); string joinedSql = string.Join("", batchedBySql.Select(d => d.CommandText)); string joinedParams = string.Join("", batchedByParams.Select(d => d.CommandText)); notBatched.First().CommandText.ShouldBe(joinedSql); notBatched.First().CommandText.ShouldBe(joinedParams); }
public void Page_IfExists_ReturnsFactory() { PageDescriptor descriptor = this.FindPage("LocatorQuery2"); ProcArgs args = new ProcArgs(typeof(int), typeof(object)); ProcFactory factory = this.engine.Proc(descriptor, args); factory.ShouldNotBeNull(); }
private IProcResult ExecuteAndGetResult(string procName, object model, ProcArgs args) { IProcLocator locator = this.Context?.Locator ?? new ProcLocator(); IProcEngine engine = this.Context?.Engine ?? new ProcEngine(null); PageDescriptor descriptor = locator.FindPage(procName, this.GetType()); ProcFactory factory = engine.Proc(descriptor, args); return(factory(model)); }
public string Sql <TModel, TResult>(Runnable <TModel, TResult> model) { IProcLocator locator = this.Context?.Locator ?? new ProcLocator(); IProcEngine engine = this.Context?.Engine ?? new ProcEngine(null); PageDescriptor descriptor = locator.FindPage("Query", this.GetType()); ProcArgs args = new ProcArgs(typeof(Runnable <TModel, TResult>), typeof(List <TResult>)); ProcFactory factory = engine.Proc(descriptor, args); return(factory(model).Buffer.ReadToEnd().Text.Trim()); }