A lot of clauses Filters/Groupby

Posts   
 
    
Sylvain60
User
Posts: 3
Joined: 09-Apr-2015
# Posted on: 09-Apr-2015 10:39:53   

Hi,

I work on a project that has about thirty tables to a size of about 1.5TB (SQL Server 2012/2014) I have some views on these tables, including a master that I use to produce reports and analyzes, creaté in Excel/word with a custom solution.

On this main view "VMAIN" I have to apply numerous filters (tens) depending on configuration. Each configurations have its criteria.

Class {abstract abstract ACriteria filter A; Filter B abstract, abstract Filter C; ...} Class Filter01: ACriteria filter {A = ...; Filter B = ..., Filter C = ...; ...}

in the second time I apply a grouping condition that can bring together a combination of several fields in a list of about thirty.

Calculations from this grouping is always the same.

To get there I generate all combinations of .NET classes: abstract class AGrouping {float compute A, B Compute int, float Compute C, ...} GroupA class: A AGrouping {string} GroupB class: B} {string AGrouping class GroupB: AGrouping {string} C GroupA_B class: AGrouping {string A, string B} GroupA_B class: AGrouping {string A, string C} GroupA_B class: AGrouping {string B, C string} GroupA_B class: AGrouping {string A, string B, C string}

I use DAPPER to perform queries. I create extensions to generate STRING which is the request, but that did not quite practical. The slightest change of names or table involves passing in all STRING risk of forgetting. The creation of new filters is also very complicated and dangerous.

I look at the side of EF (6/7), Hibernate but the performance is not very good and I felt limited me. Hibernate is even very complicated and the cost of integration seems too important. If I have to use the OVER clause by injecting myself formula is very complicated.

Other MircoOrm (petapoco, OrmLite) offer the same constraints as the current solution with Dapper.

I do not know your solution but do you see a way to implement a archtecture allowing me to operate in this way the database with your solution?

Thank you

PS: sorry for my bad english

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Apr-2015 08:17:34   

LLBLGen Pro Runtime offers the API classes. The filtering, grouping, sorting, etc., all of they are typed objects you can reuse. Specially for filtering you can use PredicateExpressions.

Also for LINQ2LLBL we support PredicateBuilder, which is a way of constructing your filter dynamically: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=14224

David Elizondo | LLBLGen Support Team
Sylvain60
User
Posts: 3
Joined: 09-Apr-2015
# Posted on: 19-Apr-2015 14:51:41   

I tried several methods, but I have not found the solution that suits me.

I created a CustomFilters type object list that are the library filters I use IPredicateExpression to create about a hundred combination of filters.

By cons for the rest it's more complicated.

I can not find a clean and simple way to attach a grouping key library and bookstore calculation.

The ideal would be to have type POCO

class ComputeType1 <KeyGroupingTypeA> { KeyGroupingTypeA keys; Double XXX; // Sum(Fields.A * Fields) float YYY; // Avg (Fields.B) int YYY; // Sum (Fields.C) / Sum(Fields.B) ... }

and I want use: List <ComputeType1> result = new ComputeType1 <KeyGroupingTypeA> Query (new FilterTypeA ());

You see how to do this?

For the same views I have more 100 combinaison of key grouping and the compute can change a lot.

thank you

Walaa avatar
Walaa
Support Team
Posts: 14986
Joined: 21-Aug-2005
# Posted on: 24-Apr-2015 13:21:43   

I created a CustomFilters type object list that are the library filters I use IPredicateExpression to create about a hundred combination of filters.

By cons for the rest it's more complicated.

I can not find a clean and simple way to attach a grouping key library and bookstore calculation.

Could you please elaborate in details or a simple and small code sample, why it's complicated to use LLBLGen Pro's Predicate system?

Sylvain60
User
Posts: 3
Joined: 09-Apr-2015
# Posted on: 25-Apr-2015 15:53:25   

My problem is not with Predicate but with groupby. I own several calculated fields (~ 30), the keys of varied groupings.

I wanted to know if there was a way to create a computational libraries (eg AveragePx = sum (FieldsStock.Qty FieldsStock.AvgPx *) / sum (FieldsStock.Qty), ...) and use the library of my choices based on grouupage key (Ticker, Country, Ticker + Country, IndexReference, IndexReference + Country + Currency ...)

because paste more than 100 times the compute for each view isn't the good way.

ty

Walaa avatar
Walaa
Support Team
Posts: 14986
Joined: 21-Aug-2005
# Posted on: 28-Apr-2015 05:43:32   

For computational fields, you can use/create EntityField/EntityField2 objects, which accepts an Expression and an Aggregate in the CTor, please check the Reference Manual.

These can later be used in a query, whether in the select list or in a predicate. You'll just need to take care of the aliasing when building the query, you'll need to set it manually.

Please check Expressions