Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> elementFilter issue in Code Generation
 

Pages: 1
LLBLGen Pro Runtime Framework
elementFilter issue in Code Generation
Page:1/1 

  Print all messages in this thread  
Poster Message
tbeyhan
User



Location:

Joined on:
23-May-2006 13:14:10
Posted:
23 posts
# Posted on: 14-Feb-2011 11:11:01.  
Hi,
I want to run some of my templates based on a custom property set on entities.
For this purpose i'm using element filter. But i couldn't manage to check the specific property exists or not.
using OutputSettingValues.CustomProperties.Keys.Count > 0 works,
but i can't test key with Contains method

Any ideas,
cheers
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 14-Feb-2011 15:50:08.  
Which version of LLBLGen Pro are you using?

  Top
tbeyhan
User



Location:

Joined on:
23-May-2006 13:14:10
Posted:
23 posts
# Posted on: 14-Feb-2011 19:47:08.  
Hi Walaa,
I'm using 3.1
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37797 posts
# Posted on: 14-Feb-2011 20:28:53.  
Please give more info, i.e. what you have tried in code which failed.

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



Location:

Joined on:
23-May-2006 13:14:10
Posted:
23 posts
# Posted on: 14-Feb-2011 22:01:13.  
Defined custom property for two entities.when i run my template for allEntities and use an element filter OutputSettingValues.CustomProperties.Keys.Count > 0 i get two files as expected.
But i can't get the same result when i use OutputSettingValues.CustomProperties.Keys.Contains("keyname") as elementFilter

Sure i'm doing something stupid but couldn't figure it out
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8098 posts
# Posted on: 15-Feb-2011 01:18:13.  
Reproduced.

Steps:
- Click F7 and go to "Task queue to execute" Sub tab
- For an specific CodeEmmiter task, put this on elementFilter:
OutputSettingValues.CustomProperties.Keys.Contains("keyname")
or
OutputSettingValues.CustomProperties.ContainsKey("keyname")
- Result: the task is executed for all the input entities, instead of just the ones that pass the criteria.

This works if the elementFilter is OutputSettingValues.CustomProperties.Keys

We will look into it.


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37797 posts
# Posted on: 15-Feb-2011 09:30:18.  
The lambda defined in elementFilter is evaluated with 'DynamicQuery' which is a reflection based simple evaluator for lambdas. In short, it can't deal with things like this, it can only deal with an object and a method called onto it e.g. Count(), but not member access of a property and then call a method on it.

I know it's a limitation, but it's what is supported. A workaround is to use a frameworksettings file and define a setting and use that setting's value in a perform rule.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
raist
User



Location:
Madrid, Spain
Joined on:
19-Apr-2010 23:57:10
Posted:
114 posts
# Posted on: 29-Apr-2013 20:27:03.  
HorribleSad workaround for .lpt templates:
1. Do not use task parameter elementFilter. Generate for all the elements
2. At the beginning of the template check the required condition.
    If false -> return (generates empty file)
3. Add a last clean template to remove all the empty files checking the condition again and using executingGenerator.DestinationRootFolder

As crappy as it is, for me it is more simple (and maintainable) than generate a custom perform method as in http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=17154&HighLight=1


  Top
AtA2k7
User



Location:

Joined on:
28-Jul-2016 09:24:13
Posted:
3 posts
# Posted on: 09-Dec-2016 10:12:58.  
How do you achive step 3 (cleanup)?

where can I find out what can be used in emitType and elementFilter parameters? cant seem to find this in the docs.

thx
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37797 posts
# Posted on: 09-Dec-2016 10:28:16.  
It's in the SDK

http://www.llblgen.com/Documentation/5.1/SDK/shipped_taskperformers.htm#codeemitter


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


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

Version: 2.1.12172008 Final.