EntityCollection.OnEntityAdding on prefetched entities

Posts   
 
    
Mikael
User
Posts: 1
Joined: 02-Oct-2007
# Posted on: 02-Oct-2007 09:50:23   

Hello!

I'm pretty new to LLBLGen and I have a quistion on EntityCollection.OnEntityAdding.

I have overloaded the EntityCollection.OnEntityAdding method to check if entityToAdd implements a certain interface and then cancel the adding of the entity to the collection if a certain property has a certain value.

The goal is that some entities should never be retreived from the database whatever the method of retreiving them.

Now, when loading some entities with a prefetchpath like this:

prefetch.Add(MyFirstEntity.PrefetchPathMySecondEntity)

those of the MyFirstEntity entities having that certain property value will be filtered away as expected. But all of the MySecondEntity entities will be loaded, even though they the match all the criteria for beeing filtered away be the OnEntityAdding method.

It seems that the OnEntityAdding method does not kick in on the prefetch collection. Is this correct, and is there some other way to do it?

/Mikael

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 02-Oct-2007 11:25:42   

to check if entityToAdd implements a certain interface and then cancel the adding of the entity to the collection if a certain property has a certain value.

If you don't want to use database filtering to limit the fetched entities based on certain values. Then maybe you need to implement the v.2.5 Authorization feature to limit the entities returned to the user based on some values.