Generating code for a subset of entities filtered by name

Posts   
 
    
vassos
User
Posts: 32
Joined: 24-Jun-2008
# Posted on: 15-Jan-2009 23:48:36   

Hi, Otis. My question is: Can I generate some code for just a set of entities? Here is an example of what I need.

namespace <[RootNamespace]>.EntityClasses {<[Foreach Entity]> //something like: <[If EntityNameIs "PersonEntity"]>//This entity is "PersonEntity"<[EndIf]> <[ NextForeach ]>

I've heard about other types of template files except TDL ones. I think they were .lpt. If my case is impossible for a TDL template please tell me whether .lpt template could do the work for me. Also can I address a .lpt template in a .templatebindings file by only setting the 'templateLanguage' to something different than TDL or it is more complicated?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 16-Jan-2009 02:45:30   

Hi vassos,

First of all I wonder why do you want to do such thing? Next, Why don't use "Object Groups"?. (Copied from manual):

With the button Create participating object subset... you can create a subset of the objects to generate code for. By default, the complete project is used for code generation so you don't need to specify anything and you can safely leave this button alone. However some scenario's, for example small tests, may require that you create a subset of the project elements and generate code for these elements. To specify a subset, click on the Create participating object subset... button. This button opens a form with the object selector already discussed in the plug-ins section. For more information about this object selector, please see: selecting participating objects. The object selector opened when the Create participating object subset... button is clicked shows no object being selected. This gives you a clean slate to define participating objects. If you decide not to use a subset, simply click Cancel. If you don't check any object and click OK, a warning is shown to inform you that you've created an empty subset and you can then decide to discard this empty subset and use the whole project, or use the empty subset. You can also manage the subsets by right-clicking the project node in project explorer and then by selecting Manage object groups from the context menu, or by selecting Manage object groups from the Project menu in the LLBLGen Pro designer menu.

And, about TDL/LTP, you can start downloading and reading the SDK manual.

David Elizondo | LLBLGen Support Team
vassos
User
Posts: 32
Joined: 24-Jun-2008
# Posted on: 16-Jan-2009 10:31:47   

With all my respect, daelmo your reply is absolutely useless to me. I asked you a simple question. Is it possible to do what I need with TDL or not. You want to know why I need this. Why is this so important to you? The reason I need this is not relevant to solving my problem.

I know about the "button Create participating object subset" and how to not generate code for particular entity. I DON'T need that!!! I need just to skip some code generating for some entities. Here is a more detailed example and I hope this time you give me a straight answer.

This is a piece of the template: linqMetaDataAdapterADODS.template

namespace <[RootNamespace]>.EntityClasses {<[Foreach Entity]> [IgnoreProperties("EntityFactoryToUse","CustomPropertiesOfType", "FieldsCustomPropertiesOfType", "Validator", "AuthorizerToUse", "AuditorToUse", "Fields", "Transaction", "ConcurrencyPredicateFactoryToUse", "TypeDefaultValueProviderToUse", "PrimaryKeyFields", "LLBLGenProEntityTypeValue", "LLBLGenProEntityName", "ActiveContext", "IsDirty", "IsNew", "ObjectID", "ParticipatesInTransaction", "IsDeserializing")] <[If HasPrimaryKey]>[DataServiceKey(<[Foreach PrimaryKeyEntityField IncludeInherited Comma]>"<[EntityFieldName]>"<[ NextForeach ]>)]<[ EndIf ]> /// <summary>partial class for adding ADO.NET specific attributes to the generated entity class</summary> partial class <[CurrentEntityName]>Entity { } <[ NextForeach ]>

This piece of code contains a foreach loop so it is repeated for all entities. I need to have a slight different ignore properties for some specific entities. For example I want to have a property with name "MyProp" ignored only when entity is "PersonEntity". The reason is that if I put it without this entity name filter "MyProp" will be added to the "IgnoreProperties" attribute for all entities. But assume that "MyProp" is a custom property that was added to "PersonEntity" by partial class. So I will have a runtime exception that all entities except "PersonEntity" does not have a definition about such a property.

So that is the reason I need a "IF" expression that checks for exact entity name and generates the code between the "If" tag and the "<[EndIf]>" only if evaluated to true.

About the TDL/LPT - ok you are right. I should search this in your documentation before asking. However now I think that maybe the lpt is not an option for me, because I want to modify the above template which is TDL and don't want to rewrite it.

About the support, you can learn much from Otis. Every time he gives me a support it is accurate and helpful. I know that he is the guru in your team, but you should try to do what he does.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39771
Joined: 17-Aug-2003
# Posted on: 16-Jan-2009 11:15:14   

Before I reply to you, I'll reply to this:

About the support, you can learn much from Otis. Every time he gives me a support it is accurate and helpful. I know that he is the guru in your team, but you should try to do what he does.

I disagree, and I think David does an excellent job and answered properly (and the answer would be mine too if I would have answered you first) and doesn't deserve an answer like you gave above. If you want me to be friendly, you should be friendly too. Please take that into account in further communication with us, as I won't be friendly to you if you aren't either. Do we understand each other?

Also:

You want to know why I need this. Why is this so important to you? The reason I need this is not relevant to solving my problem.

I'm sorry, but if we ask YOU a question, we need the information. The thing is: if we know why you want this, we can perhaps offer a workaround or an alternative to achieve the same goal. That is why we need this info. If you don't want to give it, no problem, but then it could be that you'll get the wrong answer.

Frans Bouma | Lead developer LLBLGen Pro
vassos
User
Posts: 32
Joined: 24-Jun-2008
# Posted on: 16-Jan-2009 11:24:14   

Otis wrote:

Before I reply to you, I'll reply to this:

About the support, you can learn much from Otis. Every time he gives me a support it is accurate and helpful. I know that he is the guru in your team, but you should try to do what he does.

I disagree, and I think David does an excellent job and doesn't deserve an answer like this. If you want me to be friendly, you should too. Please take that into account in further communication with us, as I won't be friendly to you if you aren't either. Do we understand each other?

Of course! I was affected and maybe I passed the border between friendly and quarrelsome conversation, for which I apologize. I don't mean to be so rude. I like your product a lot and enjoy working with it. From now on I will try myself to explain my questions and scenarios as detailed as possible.

I guess we now understand each other simple_smile .

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39771
Joined: 17-Aug-2003
# Posted on: 16-Jan-2009 11:41:32   

Good simple_smile

Now back to your question. TDL has a statement called <[If Not StringValueEquals StringValueName QuotedString]> text <[EndIf]> (see SDK Docs) where StringValueName can be a long list of things. So you can do: <[If StringValueEquals CurrentEntityName "MyEntity"]>... <[EndIf]>

Though, you can also do it differently: for the entity which you have other properties to exclude, you can also create a new partial class and add the attribute to exclude the property there. The advantage of that is that you don't have to re-generate the code and it's perhaps easier to maintain, than a template. But that's up to you.

You can always use an include template of type .lpt if nothing else helps.

Frans Bouma | Lead developer LLBLGen Pro
vassos
User
Posts: 32
Joined: 24-Jun-2008
# Posted on: 16-Jan-2009 14:01:37   

That is what I was talking about. Otis, you rule. Thank you for the support again. However I lost faith that I can manage to fix the model for ADO.NET DS. I get strange exceptions like this one:

The server encountered an error processing the request. The exception message is 'The property 'Validator' is not a valid property name for type 'Omegasoft.Omeks.BusinessObjects.EntityClasses.PsEducationQualificationEntity'. Please specify a valid property name.'. See server logs for more details.

I understand the exception but there is a "Validator" property in every entity and it is LLBL specific. So it is ignored with 'IgnoreProperties' attribute. Those bloody data services. I'm sick of them.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39771
Joined: 17-Aug-2003
# Posted on: 16-Jan-2009 14:35:45   

Is this occuring once you added for example two partial classes for the same class with Ignore attributes?

Frans Bouma | Lead developer LLBLGen Pro
vassos
User
Posts: 32
Joined: 24-Jun-2008
# Posted on: 19-Jan-2009 09:48:15   

Otis wrote:

Is this occuring once you added for example two partial classes for the same class with Ignore attributes?

No, Otis, I have only one 'IgnoreProperties' attribute on every class, because otherwise I get a compile exception that only one attribute is allowed.

Maybe the solution for running the damned ADO.NET DS is to see what the .edmx contains and hopefully to be able to understand it.