Re : Databinding custom code property field results in design time error

Posts   
 
    
Krish
User
Posts: 91
Joined: 02-Jan-2008
# Posted on: 25-Jun-2008 05:22:02   

After generating code with LLBLGen, I added a partial class to extend one of the generated entity classes.

My custom partial class code is as follows :



namespace PPS.DAL.EntityClasses
{
    
    public partial class SettingCatPlacementEntity
    {
        private string _ForDDSettingName;

        
        public string ForDDSettingName
        {
            get
            {
                _ForDDSettingName = this.SettingCatDetails.SName + " | " + this.SettingCatDetails.SettingCategory.ScName;
                return _ForDDSettingName;
            }

        }

    }

}


Now I use LLBLGenProDataSource to bind to a asp gridview control. Once I do that VS2008 (possibly VS2005) says error rendering the control. The error displayed in the design view is :

Property accessor 'ForDDSettingName' on object PPS.DAL.EntityClasses.SettingCatPlacementEntity' threw the following exception: 'Object reference not set to an instance of an object'.

Why is this error occuring?

The error occurs only at design time in design view. There is no error at run time. Also the custom property displays correctly in the grid.

Is ther any other consequences or gotchas I need to be aware of when adding custom code this way.

I am using LLBLGen Pro Final 2.5. I am using SelfServicing two class template. C# and .NET 3.5.

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 25-Jun-2008 12:41:20   

This is expected, as the related entity properties have the value 'Nothing' at design time. So you have to check if the value is Nothing. (this.SettingCatDetails & this.SettingCatDetails.SettingCategory)

Be aware that this is a performance intensive operation if you don't use prefetch paths as it will load in the grid the related entities per row with single queries due to the lazy loading