ConvertNulledReferenceTypesToDefaultValue

Posts   
 
    
M6rk
User
Posts: 37
Joined: 29-Sep-2004
# Posted on: 15-Feb-2007 17:30:12   

Hi,

I have the ConvertNulledReferenceTypesToDefaultValue=True for my "Single Class Self Servicing 2.0 SQL Server 2000" project. There is a particular entity/collection's property i would like to return nulls instead. I want to bind this entity/collection to a third party menu control - which seems to need nulls to indicate top level menu items.

How may i accomplish?

Thank you, Mark

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 16-Feb-2007 02:24:40   

I would create a partial class with a new property that is something like this and use that property. Most other solutions I thought of would affect other types or be a big task for something that may be fairly rare for you. The original property is TestName


    public partial class EmployeeEntity
    {
        /// <summary> The TestName property of the Entity Employee<br/><br/>
        /// </summary>
        /// <remarks>Mapped on  table field: "Employee"."Test_Name"<br/>
        /// Table field type characteristics (type, precision, scale, length): NChar, 0, 0, 10<br/>
        /// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
        public virtual System.String TestNameNull
        {
            get
            {
                object valueToReturn = base.GetCurrentFieldValue((int)EmployeeFieldIndex.TestName);
                return (System.String)valueToReturn;
            }
            set { SetNewFieldValue((int)EmployeeFieldIndex.TestName, value); }
        }
    }

M6rk
User
Posts: 37
Joined: 29-Sep-2004
# Posted on: 17-Feb-2007 11:33:22   

In my case, the nullable field is a value type.

To restate your suggestion:

  1. Modify the generated code by adding a new partial class.
using DmDAL.EntityClasses;
using DmDAL;
namespace DmDAL
{
  public  partial class ShortMenuEntity
  1. Add this property to partial class:
 public  partial class ShortMenuEntity
    {
        public virtual object ParentIdNull
        {
            get
            {
                object valueToReturn = base.GetCurrentFieldValue((int)ShortMenuFieldIndex.ParentId);
                return valueToReturn;
            }
            set { SetNewFieldValue((int)ShortMenuFieldIndex.TestName, value); }
        }
    }

I tried the above. During compilation an error was emitted:

Error   1   The type 'DmDAL.ShortMenuEntity' must be convertible to 'SD.LLBLGen.Pro.ORMSupportClasses.EntityBase' in order to use it as parameter 'TEntity' in the generic type or method 'SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase<TEntity>

Thank you for your help!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 17-Feb-2007 12:25:01   

I think: namespace DmDAL should be namespace DmDAL.EntityClasses

the partial class fragment you wrote is now in another namespace.

Frans Bouma | Lead developer LLBLGen Pro
M6rk
User
Posts: 37
Joined: 29-Sep-2004
# Posted on: 18-Feb-2007 13:20:00   

Otis wrote:

I think: namespace DmDAL should be namespace DmDAL.EntityClasses

the partial class fragment you wrote is now in another namespace.

That fixed the compiler error - Thank you!

Unfortunately the Telerik RadMenu is still not displayed hiarchially when binding to the LLBLGen generated collection. Apparently it has a problem binding to a datasource that does not implement IHierarchicalDataSource i.e. http://www.telerik.com/community/forums/thread/b311D-chagh.aspx

I saw your related comment about the difficulties involved in implementing this interface: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=6688&HighLight=1

I guess my options are: 1. Convert the LLBGen EnityCollection to a datatable and bind to that in codebehind. 2. Use the SqlDataSource.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Feb-2007 08:23:28   
  1. Convert the LLBGen EnityCollection to a datatable and bind to that in codebehind.

You can fetch a DynamicList or a TypedList from the start. (both are dataTables) Or you can use Projection to project an EntityCollection EntityView to a DataTable.

M6rk
User
Posts: 37
Joined: 29-Sep-2004
# Posted on: 19-Feb-2007 17:06:14   

Walaa wrote:

You can fetch a DynamicList or a TypedList from the start. (both are dataTables) Or you can use Projection to project an EntityCollection EntityView to a DataTable.

Thanks for the suggestion.

I tried this and it failed to display menu hiearchially. The failure may be due to the handling of a null parentId field by returning "0". Unfortunately I need to move on, so I will bind the RadMenu to a SqlDataSource for now.

Thank you all for your help! Mark

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 19-Feb-2007 18:07:40   

The hierarchical data interface isn't supported on the controls as you've read, so indeed you need to find another solution in that case.

Frans Bouma | Lead developer LLBLGen Pro