Print Page | Close Window

GetEntityGroups fails to find any entities

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1305
Printed Date: 27-Apr-2025 at 4:55pm


Topic: GetEntityGroups fails to find any entities
Posted By: jsobell
Subject: GetEntityGroups fails to find any entities
Date 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



Replies:
Posted By: kimj
Date 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.


Posted By: jsobell
Date 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


Posted By: kimj
Date 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();



Print Page | Close Window