New Posts New Posts RSS Feed: Add entity to NavigationEntityProperty without retrieving values
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Add entity to NavigationEntityProperty without retrieving values

 Post Reply Post Reply
Author
murray.bryant View Drop Down
Groupie
Groupie


Joined: 11-Jan-2012
Location: Australia
Posts: 44
Post Options Post Options   Quote murray.bryant Quote  Post ReplyReply Direct Link To This Post Topic: Add entity to NavigationEntityProperty without retrieving values
    Posted: 03-Apr-2013 at 11:46pm
I have the following code

  NavigationEntityProperty noteProp =
                        entity.EntityAspect.EntityMetadata.NavigationProperties.FirstOrDefault(
                            p => string.Equals(p.Name, "Notes"));
  var list = noteProp.GetValue(entity) as IList;

 list.Add(dSourceNote);

When I cast as IList the list is populated from the database.

I have no need to access the other values and for performance reasons in this case I would like to just add to the navigationentityproperty without selecting the other values from the database.

Is there any way I can do this?

thanks

Murray
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 04-Apr-2013 at 10:33am
Murray,

If you don't want the navigation property to retrieve entities from the database, you could force entity to act as if all its Notes have already been loaded:


EntityType.PropertyMetadata.Notes.GetEntityReference(entity).IsLoaded = true;


You can find additional information about navigation properties and data retrieval at http://drc.ideablade.com/devforce-2012/bin/view/Documentation/navigation-properties-data-retrieval.
Back to Top
murray.bryant View Drop Down
Groupie
Groupie


Joined: 11-Jan-2012
Location: Australia
Posts: 44
Post Options Post Options   Quote murray.bryant Quote  Post ReplyReply Direct Link To This Post Posted: 04-Apr-2013 at 2:55pm
thanks that works great
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down