I beleive its ready now.
This commit is contained in:
parent
10fbe01674
commit
7392c25257
@ -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]
|
[Fact]
|
||||||
public void NonGeneric()
|
public void NonGeneric()
|
||||||
{
|
{
|
||||||
@ -80,5 +96,18 @@ namespace PoweredSoft.DynamicQuery.Test
|
|||||||
Assert.All(result.Data, t => Assert.IsType<CustomerModel>(t));
|
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));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ namespace PoweredSoft.DynamicQuery
|
|||||||
public List<TRecord> Data { get; set; }
|
public List<TRecord> Data { get; set; }
|
||||||
|
|
||||||
public bool ShouldSerializeAggregates() => Aggregates != null;
|
public bool ShouldSerializeAggregates() => Aggregates != null;
|
||||||
|
|
||||||
|
public bool ShouldSerializeData() => Data != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// just result
|
// just result
|
||||||
@ -44,7 +46,9 @@ namespace PoweredSoft.DynamicQuery
|
|||||||
{
|
{
|
||||||
public string GroupPath { get; set; }
|
public string GroupPath { get; set; }
|
||||||
public object GroupValue { 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 List<IGroupQueryResult<TRecord>> SubGroups { get; set; }
|
||||||
|
|
||||||
|
public bool ShouldSerializeSubGroups() => HasSubGroups;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ namespace PoweredSoft.DynamicQuery
|
|||||||
services.TryAddTransient<IGroup, Group>();
|
services.TryAddTransient<IGroup, Group>();
|
||||||
services.TryAddTransient<IQueryCriteria, QueryCriteria>();
|
services.TryAddTransient<IQueryCriteria, QueryCriteria>();
|
||||||
services.TryAddTransient<IQueryHandler, QueryHandler>();
|
services.TryAddTransient<IQueryHandler, QueryHandler>();
|
||||||
//services.TryAddTransient<IQueryHandlerAsync, QueryHandlerAsync>();
|
services.TryAddTransient<IQueryHandlerAsync, QueryHandlerAsync>();
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 | [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<T, T2> | [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<T, T2> | [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<T, T2> | 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<T, T2> | [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)**
|
Loading…
Reference in New Issue
Block a user