Calculation

Posts   
 
    
etick
User
Posts: 75
Joined: 26-Aug-2008
# Posted on: 10-May-2013 09:26:24   

I am thinking about building in a calculation model into the generated llblgen code. At what level it would we best to do this?

It should be possible to do calculation over multiple different entities. So

EntityA->FieldC = EntityA->FieldA + EntityA->FieldB

EntityA->FieldA = EntityB->FieldA + EntityC->FieldC

EntityA->FieldA = EntityB->FieldA + Sum(EntityC->FieldC)

My problem is at which place i can best add this source in such a way that the program code is transparent using it.

And also use it in collections etc..

regards

Eddy

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 10-May-2013 11:39:58   

Not sure what you are trying to do. And I see circular dependencies on FieldA, is this intended or a typo?

etick
User
Posts: 75
Joined: 26-Aug-2008
# Posted on: 10-May-2013 13:32:54   

Walaa wrote:

Not sure what you are trying to do. And I see circular dependencies on FieldA, is this intended or a typo?

We want to create a calculation engine based on the entity model, i don't see the typo? So that data retrieved is Always calculated correctly and the calculated data retrieval is transparent. Something like excel but at the data level. Grids have these functions but when paging etc.. it does not work as expected. (virtual data grids)

Excel loads everything in mem..

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-May-2013 08:38:12   

I presume you have all of that expression in an excel file, right? Is so, What are its columns and how do you represent the fields and calculations on it?

About your question on "where it should be", maybe you can create your own project that references only the ORMSupportClasses.

When you load your excel, somehow you have to translate those calculations into some expression system. Like "Customer.CustomerId" translates into a EntityFieldCore, the "+" sign translates into a Sum operator, etc.

Then, 'somehow' you should traverse store that in a Dictionary<EntityFieldCore, Expression>, where expression is some class that store the operations graph, etc. I think you have all that figured out. Where to place it? As I said before, I would put it in a separate "Calculations" project. You can't put it on the Generic generated project because you don't now the operations in advance.

David Elizondo | LLBLGen Support Team
etick
User
Posts: 75
Joined: 26-Aug-2008
# Posted on: 11-May-2013 10:57:29   

daelmo wrote:

I presume you have all of that expression in an excel file, right? Is so, What are its columns and how do you represent the fields and calculations on it?

About your question on "where it should be", maybe you can create your own project that references only the ORMSupportClasses.

When you load your excel, somehow you have to translate those calculations into some expression system. Like "Customer.CustomerId" translates into a EntityFieldCore, the "+" sign translates into a Sum operator, etc.

Then, 'somehow' you should traverse store that in a Dictionary<EntityFieldCore, Expression>, where expression is some class that store the operations graph, etc. I think you have all that figured out. Where to place it? As I said before, I would put it in a separate "Calculations" project. You can't put it on the Generic generated project because you don't now the operations in advance.

No i don't want to use excel, i created my own calculation engine. Yes i will create a seperate project but the point is at what level i can build it into the generated code from llblgen.

Should it be at CommonEntityBase.Custom.cs level, so that is my main problem where to put it.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-May-2013 07:20:55   

etick wrote:

No i don't want to use excel, i created my own calculation engine. Yes i will create a seperate project but the point is at what level i can build it into the generated code from llblgen.

Ok, I misunderstood you there.

etick wrote:

Should it be at CommonEntityBase.Custom.cs level, so that is my main problem where to put it.

I don't know to be honest. I don't know how exactly you expect to apply your calculation engine into the entities.

Could you please show us an example of how would you expect to use your calculations? For instance: you fetch a EntityCollection<OrderEntity> from your DB, pefetching the Customer and OrderDetails. Then, somehow you want to apply that calculation engine to that, Am I right? or Is it more for new entities? So, at what point you plan to do this, and how. Given that answers may help us to understand your situation and give an advise.

David Elizondo | LLBLGen Support Team