Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> LLBL Modify Field in Predicate/Dynamic Bucket Creation
 

Pages: 1
LLBLGen Pro Runtime Framework
LLBL Modify Field in Predicate/Dynamic Bucket Creation
Page:1/1 

  Print all messages in this thread  
Poster Message
Suchong
User



Location:

Joined on:
02-Aug-2019 17:26:10
Posted:
3 posts
# Posted on: 02-Aug-2019 17:43:29.  
Hi all,

Using llbl 5.5, SQLServer2017
I am trying to use a single bucket to fetch 4 different type of entity, let me explain :

I have a viewEntity(GlTransactionEntity) which is based on 4 children entity (IC,JC,AR and APTransaction), doing a GetEntities on the view entity is too slow because of the way we made our database, so instead i need to fetch all the entities by fetching the 4 children entity one after the other with the same filter and then make the view entity based on them.

The problem is that I want to do it so that the next person using my fetch method won't have to make 4 different RelationPredicateBucket.

Is there any way i can construct my Bucket using, let say ,GLTransactionFields.Id and then change the instance of GLTransactionFields.Id to ICTransactionFields.Id before fetching?

Or maybe i can use a Custom Relation and when using fetch entity on GLTransaction the query knows to fetch the Ic,Jc,Ar,Ap based on the filter instead of the Gl directly

Code:

CustomRelation.AddEntityFieldPair(EntityFieldFactory.Create(GlTransactionFieldIndex.Id),
                                             EntityFieldFactory.Create(IcTransactionFieldIndex.Id));
            CustomRelation.AddEntityFieldPair(EntityFieldFactory.Create(GlTransactionFieldIndex.Id),
                                             EntityFieldFactory.Create(JcTransactionFieldIndex.Id));
            CustomRelation.AddEntityFieldPair(EntityFieldFactory.Create(GlTransactionFieldIndex.Id),
                                             EntityFieldFactory.Create(ApTransactionFieldIndex.Id));
            CustomRelation.AddEntityFieldPair(EntityFieldFactory.Create(GlTransactionFieldIndex.Id),
                                             EntityFieldFactory.Create(ArTransactionFieldIndex.Id));



and instead of doing :

Code:

var Bucket = new PredicateExpression(IcTransactionFields.DetailSourceTypeCode == "REC");
IcManager.Fetch(Bucket)
Bucket = new PredicateExpression(JcTransactionFields.DetailSourceTypeCode == "REC");
JcManager.Fetch(Bucket)
Bucket = new PredicateExpression(ArTransactionFields.DetailSourceTypeCode == "REC");
ArManager.Fetch(Bucket)
Bucket = new PredicateExpression(ApTransactionFields.DetailSourceTypeCode == "REC");
ApManager.Fetch(Bucket)



I could do :
Code:

var Bucket = new PredicateExpression(GENERICFIELD.DetailSourceTypeCode == "REC");
IcManager.Fetch(Bucket);
JcManager.Fetch(Bucket);
ArManager.Fetch(Bucket);
ApManager.Fetch(Bucket)
)

or something of the sort.

The last solution i thought of would be to make a field that changes based on the entity that i want to fetch at runtime but i doubt that is possible.

Thank you for your help
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37405 posts
# Posted on: 03-Aug-2019 09:56:16.  
I have a bit of a hard time understand what you're trying to do. You have a view GlTransaction and 4 subtypes and fetching all GlTransaction instances was too slow? However what you're trying to accomplish instead is unclear to me, as one way or the other: the joins have to happen (if that's what's going on, you didn't explain that Regular Smiley ).

What exactly makes the fetch slow? (I also don't know what you mean with 'GetEntities', is that your own method? )


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Suchong
User



Location:

Joined on:
02-Aug-2019 17:26:10
Posted:
3 posts
# Posted on: 05-Aug-2019 13:17:26.  
the objective i'm trying to acheive is to seamlessly fetch the 4 table. The next dev would only have to construct one bucket with GlTransactionField and i would modify the bucket so that it would use ICTransactionFields instead. But after a bit of research on my side, i'm afraid it's not possible to modify a bucket after it was created. Because for now it forces us to create 4 RelationBucket with the same condition but with different fields which is what i'm trying to avoid. Yes the GetEntities is our method that call the source adapter to fetch the entity with the according bucket. Thank you for your help !
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14470 posts
# Posted on: 05-Aug-2019 22:49:58.  
You want to build a method that masks the creation of 4 predicateBuckets to the developers who would consume your method.
In the same sense I don't see a problem of you using 4 different perdicateBuckets in your own method which would accept parameters for different fields to filter.
The developers would directly consume your method, which encapsulates everything, and which would be simply coded without the need for any extra code to generalize the predicates.


  Top
Suchong
User



Location:

Joined on:
02-Aug-2019 17:26:10
Posted:
3 posts
# Posted on: 06-Aug-2019 13:35:48.  
Yeah exactly! I had no choice but to do what you said, the only things that rubs me the wrong way is that we will have to create 4 different predicate everytime we want to get these entities. I know for one time it is not that time consuming but if we want to fetch these entities 20 times in our application, that makes 80 bucket creation instead of 20 and makes a lot a duplicate code with just one or two different fields (same fields name as well). Thank you for your help!
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.