Additional namespaces for all entities

Posts   
 
    
Jaz
User
Posts: 31
Joined: 24-Feb-2006
# Posted on: 27-Aug-2009 16:05:28   

Hello,

I tried searching throughout all the current threads, but couldn't find an adequate answer. I use LLBLGen 2.6 on .NET 3.5 projects. I often use the "Custom Entity code" region inside an entity to add additional stuff. I tend to follow the "a method/logic related to a class should be declared in that class" principle as much as I can. The problem is when I need to use methods from external assemblies. I can reference them all right, but I have a problem with namespaces. I have a need to reference certain namespaces for all the entities. For example, even System.Linq namespace is not present in the entity definition, so if I want to do Linq operations on a collection of child entities, I can't do that, at least not straightforward.

I know I can add the namespace in the "AdditionalNamespaces" region, but I need to do that manually for each namespace/entity.

I also know about your "additional namespaces" plugin in the designer, but it's not satisfying because as I keep adding/removing entities I need to either add those namespaces manually for each new entity or run a designer plugin with remove all/add all kind of sequence ("remove all" is needed since "add all" creates duplicates).

The third way is to use the full namespace definition of the external methods, which looks ugly, especially for extension methods.

So, I know I have these 3 different workarounds, but each of them takes additional time and attention. I'd really like to have a kind of "set it and forget it" global option. Since this is not a critical matter, I know I'll probably have to wait a long time, but I'd like to ask you if you could be so kind to provide this feature at least in the next version if not sooner.

Best Regards,

Jaz

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 27-Aug-2009 22:19:22   

I'll forward your request to the development team for them to take a look.

Matt

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39861
Joined: 17-Aug-2003
# Posted on: 28-Aug-2009 10:16:29   

In v3 this is solved properly simple_smile - at the project level you can define defaults for additional interfaces, additonal namespaces and attributes for various elements (if applicable of course, so namespaces/interfaces only for entities), with macros like '{$Name}' - per element you can decide if you want to 'inherit' these defaults (which is the default) or not (uncheck a checkbox) and add specific interfaces/attributes/namespaces for that element. - per framework, there are defaults defined already when you create a project. This means that for example for the LLBLGen pro framework, when you create a project, the default attribute for single-entity navigators is Browsable($false). You can remove it there to make all those navigators lose their attribute, or decide per navigator to do that.

This thus solves all problems you have and makes adding/editing these elements pretty simple and straightforward. It took some work, but it works very efficient. It also allows you to define attributes with macros on various elements, which for example makes it possible to define datacontract and validation attributes on entities/fields etc.

For v2.6, you have to deal with the attribute, I'm afraid. It's not all problematic though: LLBLGen Pro contains designer events. You probably haven't used them much (if at all) but you can write a simple plugin (or for example modify the existing one a bit) and bind that plugin to the event which is raised when an entity is added. This automates the addition for you.

Frans Bouma | Lead developer LLBLGen Pro
Jaz
User
Posts: 31
Joined: 24-Feb-2006
# Posted on: 28-Aug-2009 12:05:29   

Thx for the quick reply. I'm affraid I'll have to wait for the V3, I don't have much extra time to spend on this right now. However, since you said it's that easy for V2.6, I'm not sure I understood the whole procedure, is there a tutorial somewhere that you can provide or any other guidelines?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39861
Joined: 17-Aug-2003
# Posted on: 28-Aug-2009 12:07:03   

Which procedure are you referring to? the plugin or the v3 feature?

Frans Bouma | Lead developer LLBLGen Pro
Jaz
User
Posts: 31
Joined: 24-Feb-2006
# Posted on: 01-Sep-2009 11:39:24   

I meant the guidelines for the V2.6 plugin.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 01-Sep-2009 12:10:48   

Please check Working with plugins. The plugin source to look at is the pluralization plugin code which is a system plugin, the ones which show up in the bind dialog (so type should be: PluginType.System).

Also you may check the "Implementing a plug-in" section in the SDK manual, found in the downloadable SDK package.