views:

38

answers:

1

Hi all,

This is probably a complete noobie error.

My deepload is loading my related entitied fine and T Entity is correctly populated, but when I go back to the original call it hasnt kept the updates?

Now I'm sure EntityObjects are reference types (stupid question, but im doubting myself here)

So I shouldnt need to pass it back.

here is my deep load:

   public void DeepLoad(T entity, Type[] childTypes)
    {
           Type baseType;
           HasBaseType(typeof (T), out baseType);
           var entitySetName = ProviderHelper.GetEntitySetName(Context, baseType.Name);

           var query = Context.CreateQuery<T>(entitySetName);

           foreach (var childType in ProviderHelper.GetChildTypeNames(childTypes).Split(','))
           {
                  query = query.Include(childType);
           }
                  entity = query.SingleOrDefault();
}

any help including finger pointing and laughing is excepted :)

A: 

Looks like EntityObjects are Value types not Reference types, because when I change my method to the below, it all works as it should.

public void DeepLoad(ref T entity, Type[] childTypes)
{

    Type baseType;
    HasBaseType(typeof (T), out baseType);
    var entitySetName = ProviderHelper.GetEntitySetName(Context, baseType.Name);

    var query = Context.CreateQuery<T>(entitySetName);

    foreach (var childType in ProviderHelper.GetChildTypeNames(childTypes).Split(','))
    {
        query = query.Include(childType);
    }
    entity = query.SingleOrDefault();
}

I still think Im missing something here though... any views on this?

JamesStuddart