Hi,

This is a bit difficult to describe but I will give it a go:

We have an entity called 'PadObjectEntity' which is defined as follows:

namespace Projecten.Model.Entities
{
    [TableMapping("PadObject")]
    public partial class PadObjectEntity : CitObjectEntity
    { ...

        [TableMapping("CitObject")]
    public partial class CitObjectEntity : PadRootEntity
    {
        /// <summary>
        /// Dit Id is de verbinding van deze class met het object in Control IT.
        /// </summary>
        [Field(Nullable = false)]
        [Metadata(IsImmutable = true)]
        public int CitObjectId { get; set; }

        /// <summary>
        /// Dit is de verwijzing naar de groep waaronder dit object in de hierarchie thuis hoort.
        /// </summary>
        [Field(Nullable = true), FieldMapping("FolderId")]
        public FolderEntity Folder { get; set; }
            ...

When a CollectionChanged for a certain list is invoked a series of routines is started updating lists in a hierarchy (tree like structure) to update lists for parent nodes in the tree.

At one point the routines get to the function below which is declared on the 'PadObjectEntity':

        void StatusListCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
    {
        Folder.StatussenList.HandleCollectionChanged<PadStatusEntity>(e);
    }

We get a NullReferenceException on the 'Folder' part of that call which is strange. I've looked the Entity up in the DB. It has key: 6653 which looks like this:

Id=6653, TypeId=126, CitObjectId=32100, FolderId=6443

Meaning there is a FolderId present for this CitObjectEntity. It looks as if DO did not fetch the Entity from the DB.

I've also looked the 'Folder' up in the DB and it's there:

Id=6443, TypeId=125, OpdrachtgeverId=NULL, MOSFolderId=1333, Naam=Martini, FolderId=5227

It is expected behavior for DO to fetch this Entity from the DB prior to executing the 'Folder' reference in the CitObjectEntity, right?

Regards Paul

asked Aug 12 '13 at 09:27

Paul%20Sinnema's gravatar image

Paul Sinnema
261878896

edited Aug 12 '13 at 09:33

Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA