New Posts New Posts RSS Feed: GetEntityGroups fails to find any entities
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

GetEntityGroups fails to find any entities

 Post Reply Post Reply
Author
jsobell View Drop Down
Groupie
Groupie
Avatar

Joined: 02-Apr-2009
Location: Australia
Posts: 80
Post Options Post Options   Quote jsobell Quote  Post ReplyReply Direct Link To This Post Topic: GetEntityGroups fails to find any entities
    Posted: 04-Jun-2009 at 6:28pm
Hi,

I assume the values returned by GetEntityGroups are from an internal cache because this returns an empty collection when first called.
If you view the DomainModelEntityManager in the VS2008 object watcher, then it becomes populated.
It looks like the call needs to check first to see if the collections is empty and populate it if necessary.

Can you tell me (as a workaround) what property I need to read to force this to be populated the first time?

Cheers,
 Jason
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 05-Jun-2009 at 10:31am
We haven't done a very good job at documenting the EntityGroup, but it's primarily intended for internal use, with the exception of setting handlers for its events.
 
As you've found, GetEntityGroups just returns the existing EntityGroups from the cache, it doesn't create or populate these groups.  Each EntityGroup is usually created as data is queried, since the EntityGroup serves as the container for each entity type. 
 
To make things confusing, the GetEntityGroup<T> and GetEntityGroup(type) methods on the EntityManager will both create the EntityGroup if it doesn't exist.
 
The only time you should need to use the EntityGroup is to set up handlers for the EntityPropertyChanging, EntityPropertyChanged, EntityChanging or EntityChanged events.  In most, if not all, other cases there's a better way of doing something than using one of the properties or methods of the EntityGroup.
Back to Top
jsobell View Drop Down
Groupie
Groupie
Avatar

Joined: 02-Apr-2009
Location: Australia
Posts: 80
Post Options Post Options   Quote jsobell Quote  Post ReplyReply Direct Link To This Post Posted: 16-Jun-2009 at 8:11am
OK, well I was looking at this function to retrieve a list of all of the entity collection types, as we've set up a mini database that we would like to read all records from then serialize out again as a datasource for mocking during unit tests.
We can load them one at a time, but a simple loop calling a Linq fetch on each would be ideal.
Is there anything in the library that returns a list of all entity objects and/or collections, or do I have to specify them manually?

Cheers,
  Jason
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 16-Jun-2009 at 8:28am
I was going to say use the GetEntityTypes() function on the EntityMetadataStore, but see that it's internal for some reason.  Oh well, I'll look into that, but you can instead use the undocumented KnownTypeHelper.GetEntityTypes() method.
 
    using IdeaBlade.EntityModel;
    var entityTypes = KnownTypeHelper.GetEntityTypes();
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down