I beleive its ready now.

This commit is contained in:
David Lebee 2019-03-22 16:17:19 -05:00
parent 10fbe01674
commit 7392c25257
4 changed files with 36 additions and 3 deletions

View File

@ -55,6 +55,22 @@ namespace PoweredSoft.DynamicQuery.Test
}
}
private class MockQueryConvertGenericInterceptor2 :
IQueryConvertInterceptor<Customer, CustomerModel>
{
public CustomerModel InterceptResultTo(Customer entity)
{
var customer = entity;
var personModel = new CustomerModel
{
Id = customer.Id,
FirstName = customer.FirstName,
LastName = customer.LastName
};
return personModel;
}
}
[Fact]
public void NonGeneric()
{
@ -80,5 +96,18 @@ namespace PoweredSoft.DynamicQuery.Test
Assert.All(result.Data, t => Assert.IsType<CustomerModel>(t));
});
}
[Fact]
public void Generic2()
{
MockContextFactory.SeedAndTestContextFor("ConvertibleIntereceptorTests_Generic2", TestSeeders.SimpleSeedScenario, ctx =>
{
var criteria = new QueryCriteria();
var queryHandler = new QueryHandler();
queryHandler.AddInterceptor(new MockQueryConvertGenericInterceptor2());
var result = queryHandler.Execute<Customer, CustomerModel>(ctx.Customers, criteria);
Assert.All(result.Data, t => Assert.IsType<CustomerModel>(t));
});
}
}
}

View File

@ -25,6 +25,8 @@ namespace PoweredSoft.DynamicQuery
public List<TRecord> Data { get; set; }
public bool ShouldSerializeAggregates() => Aggregates != null;
public bool ShouldSerializeData() => Data != null;
}
// just result
@ -44,7 +46,9 @@ namespace PoweredSoft.DynamicQuery
{
public string GroupPath { get; set; }
public object GroupValue { get; set; }
public bool HasSubGroups { get; set; }
public bool HasSubGroups => SubGroups != null && SubGroups.Count > 1;
public List<IGroupQueryResult<TRecord>> SubGroups { get; set; }
public bool ShouldSerializeSubGroups() => HasSubGroups;
}
}

View File

@ -18,7 +18,7 @@ namespace PoweredSoft.DynamicQuery
services.TryAddTransient<IGroup, Group>();
services.TryAddTransient<IQueryCriteria, QueryCriteria>();
services.TryAddTransient<IQueryHandler, QueryHandler>();
//services.TryAddTransient<IQueryHandlerAsync, QueryHandlerAsync>();
services.TryAddTransient<IQueryHandlerAsync, QueryHandlerAsync>();
return services;
}
}

View File

@ -219,4 +219,4 @@ Interceptor | Interface
----------------------------------|---------------------------------------------------------------------------------------|-------------------------------------------------------------|------------------------------------------------------------------------------------------------
IQueryConvertInterceptor | [interface](../master/PoweredSoft.DynamicQuery.Core/IQueryConvertInterceptor.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/ConvertibleInterceptorTests.cs) | This interceptor allows you to replace the object that is being returned by the query, by another object instance
IQueryConvertInterceptor&lt;T, T2&gt; | [interface](../master/PoweredSoft.DynamicQuery.Core/IQueryConvertInterceptor.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/ConvertibleInterceptorTests.cs#L72) | This interceptor allows you to replace the object that is being returned by the query, by another object instance **(restricts the source)**
IQueryConvertInterceptor&lt;T, T2&gt; | coming soon | coming soon | This interceptor allows you to replace the object that is being returned by the query, by another object instance **(restricts the source & output)**
IQueryConvertInterceptor&lt;T, T2&gt; | [interface](../master/PoweredSoft.DynamicQuery.Core/IQueryConvertInterceptor.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/ConvertibleInterceptorTests.cs#L101) | This interceptor allows you to replace the object that is being returned by the query, by another object instance **(restricts the source & output)**