selfservicing ...disable the entity creation when is it null

Posts   
 
    
Banane avatar
Banane
User
Posts: 67
Joined: 01-Sep-2004
# Posted on: 27-Jul-2005 19:09:28   

Is there a way to disable the creating of a new entity, in selfservicing, for all the entities...

I want to set this.<ENTITY>ReturnsNewIfNotFound = false by default for all !

We are having a lot of problems because it is trying to create new entities...

thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39618
Joined: 17-Aug-2003
# Posted on: 27-Jul-2005 19:16:11   

Use a template which you bind to the template ID Custom_EntityInitializationTemplate. This template then should contain code which sets teh flags to false. By using that template, your generated code will have every entity have this setting set to the value you want. Please see the documentation: "Using the generated code - Adding your own code to the generated classes" to learn how to set this up.

As this feature does more bad than good for some people, an option will be added to 1.0.2005.1 which will allow you to set this in the gui.

Frans Bouma | Lead developer LLBLGen Pro
Banane avatar
Banane
User
Posts: 67
Joined: 01-Sep-2004
# Posted on: 27-Jul-2005 19:18:50   

HEHE I was about to ask you that !! In the UI it is good sunglasses

thanks a lot !

Banane avatar
Banane
User
Posts: 67
Joined: 01-Sep-2004
# Posted on: 27-Jul-2005 19:20:18   

Otis wrote:

Use a template which you bind to the template ID Custom_EntityInitializationTemplate. This template then should contain code which sets teh flags to false. By using that template, your generated code will have every entity have this setting set to the value you want. Please see the documentation: "Using the generated code - Adding your own code to the generated classes" to learn how to set this up. .

Is the property to set will be <entity>ReturnsNewIfNotFound = false ??

here is the code for my activity entity....what do I have to change??

isNew ?


    /// <summary>
        /// Initializes the class with empty data, as if it is a new Entity.
        /// </summary>
        /// <param name="propertyDescriptorFactoryToUse">PropertyDescriptor factory to use in GetItemProperties method of contained collections. Complex databinding related.</param>
        /// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
        private void InitClassEmpty(IPropertyDescriptorFactory propertyDescriptorFactoryToUse, IEntityFactory entityFactoryToUse)
        {
            base.Fields = EntityFieldsFactory.CreateEntityFieldsObject(EXCOL.DAL.EntityType.ActivityEntity);
            base.IsNew=true;
            base.EntityFactoryToUse = entityFactoryToUse;
            base.Validator = new ActivityValidator();
            
            // __LLBLGENPRO_USER_CODE_REGION_START InitClassEmpty
            // __LLBLGENPRO_USER_CODE_REGION_END
 // ***STUFF HERE *** //
            InitClassMembers(propertyDescriptorFactoryToUse, entityFactoryToUse);
        }
        

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39618
Joined: 17-Aug-2003
# Posted on: 28-Jul-2005 10:30:55   

Banane wrote:

Otis wrote:

Use a template which you bind to the template ID Custom_EntityInitializationTemplate. This template then should contain code which sets teh flags to false. By using that template, your generated code will have every entity have this setting set to the value you want. Please see the documentation: "Using the generated code - Adding your own code to the generated classes" to learn how to set this up. .

Is the property to set will be <entity>ReturnsNewIfNotFound = false ??

No: __fieldnameMappedOnRelation_ReturnsNewIfNotFound = false;

See template below. simple_smile


here is the code for my activity entity....what do I have to change??

isNew ?


    /// <summary>
        /// Initializes the class with empty data, as if it is a new Entity.
        /// </summary>
        /// <param name="propertyDescriptorFactoryToUse">PropertyDescriptor factory to use in GetItemProperties method of contained collections. Complex databinding related.</param>
        /// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
        private void InitClassEmpty(IPropertyDescriptorFactory propertyDescriptorFactoryToUse, IEntityFactory entityFactoryToUse)
        {
            base.Fields = EntityFieldsFactory.CreateEntityFieldsObject(EXCOL.DAL.EntityType.ActivityEntity);
            base.IsNew=true;
            base.EntityFactoryToUse = entityFactoryToUse;
            base.Validator = new ActivityValidator();
            
            // __LLBLGENPRO_USER_CODE_REGION_START InitClassEmpty
            // __LLBLGENPRO_USER_CODE_REGION_END
 // ***STUFF HERE *** //
            InitClassMembers(propertyDescriptorFactoryToUse, entityFactoryToUse);
        }
        

Where 'stuff here' is mentioned, the include template is injected, so copy the following to a file and bind it to Custom_EntityInitializationTemplate in a custom template set. See the documentation how to bind that.


<[Foreach RelatedEntity ManyToOne CrLf]><[If Not MappedFieldRelationIsHidden]>          _<[CaseCamel MappedFieldNameRelation]>ReturnsNewIfNotFound=false;<[EndIf]><[NextForeach]>
<[Foreach RelatedEntity OneToOne CrLf]><[If Not MappedFieldRelationIsHidden]>           _<[CaseCamel MappedFieldNameRelation]>ReturnsNewIfNotFound=false;<[EndIf]><[NextForeach]>

this then will set the flags for ALL related 1:1 and m:1 entities to true, which means null is always returned simple_smile

(edit)hmm. I discover an issue where InitClassMembers is called after this include template. InitClassMembers set the flags to true. This is only the case when you initialize an empty new entity: CustomerEntity c = new CustomerEntity();

Not when you fetch an entity. I'm now fixing that.

(edit2): OK. I'd like to ask you to download the new template archive from the customer area, which make sure the InitClassMembers() call is done BEFORE the init template include, so your init template 's code's work isn't overwritten by InitClassMembers.

This feature was meant to make life easier, to avoid null reference exceptions at runtime, but it turned out to be real nightmare. As I'm sick and tired of it now, I'll add the option to 1.0.2005.1 even if that will make the code's workings change by a switch of a preference setting. I mean, I never ever want threads like these pop up ever again: http://forums.asp.net/1001945/ShowPost.aspx

Frans Bouma | Lead developer LLBLGen Pro
Banane avatar
Banane
User
Posts: 67
Joined: 01-Sep-2004
# Posted on: 28-Jul-2005 20:10:29   

thanks I will try that or mabye we will wait for the 2005 release....smile when do you plan to realese it?

For myself I like your product a lot Franz. It is easy to use and the support it GREAT ! simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39618
Joined: 17-Aug-2003
# Posted on: 28-Jul-2005 20:34:46   

Banane wrote:

thanks I will try that or mabye we will wait for the 2005 release....smile when do you plan to realese it?

Well, when it's done! wink . I keep pushing myself to get it out the door a.s.a.p. but I also know that it should be done properly not rushed. Nevertheless, it took me a couple of weeks to get the code refactored to get inheritance implemented in the runtime lib and templates, and I'm halfway there (the rest is straight forward, all tough problems except one is solved). I hope to have a beta done later in august, and regularly the final is tehn ready a month after that simple_smile

For myself I like your product a lot Franz. It is easy to use and the support it GREAT ! simple_smile

Thanks! smile

Frans Bouma | Lead developer LLBLGen Pro
Banane avatar
Banane
User
Posts: 67
Joined: 01-Sep-2004
# Posted on: 29-Jul-2005 21:34:44   

COOL It tryed it and It is working great !

thanks a lot sunglasses

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39618
Joined: 17-Aug-2003
# Posted on: 29-Jul-2005 21:36:07   

cool! simple_smile

Frans Bouma | Lead developer LLBLGen Pro
jsaylor
User
Posts: 37
Joined: 20-Sep-2004
# Posted on: 13-May-2009 17:38:42   

(using LL v2.6...)

I know this is an old thread, but while it reads like Frans solved it in the UI waaaaayyyy back, I can't seem to find it anywhere.... confused

I have an entity with a Relation Field based on an Entity Field which is nullable. I see where the generated code inits the _[fieldName]ReturnsNewIfNotFound = true, but I can't find any way to change that behavior.

I could go the template route as the start of the thread suggests, but since Frans later said he made it accessible in the UI, I was hoping to just change it there. I was expecting to see a checkbox with the others on the Field Properties tab for "ReturnsNewIfNotFound", am I missing something?

As always, appreciation in advance!

Cheers, Jeff

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 14-May-2009 06:11:34   

Hi Jeff,

The property is called LazyLoadingWithoutResultReturnsNew and you can found it on "User Preferences" or "Project Properties" simple_smile

Next time please start a new thread.

David Elizondo | LLBLGen Support Team
jsaylor
User
Posts: 37
Joined: 20-Sep-2004
# Posted on: 14-May-2009 15:36:52   

daelmo wrote:

Hi Jeff, The property is called LazyLoadingWithoutResultReturnsNew and you can found it on "User Preferences" or "Project Properties" simple_smile

Found it, cool. Oh, this might not be the right venue to suggest a feature (per the next point, below) but I could see wanting this setting on a per entity basis.

daelmo wrote:

Next time please start a new thread.

frowning You're right, I should have ref'd this thread from a new one instead of extending it - will do better next time. wink