Target Per Hierarchy and DeleteEntitiesDirectly

Posts   
 
    
mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 20-Jun-2008 00:23:42   

Hello,

I have a table called Schedules, it contains different types of schedules. The base entity (ScheduleEntity) is abstract.

If I issue a a DeleteEntitiesDirectly, I get the following exception:

Adapter.DeleteEntitiesDirectly(GetType(ScheduleEntity), New RelationPredicateBucket(ScheduleFields.CampaignID = CampaignID))

No parameterless constructor defined for this object.

at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.DeleteEntitiesDirectly(Type typeOfEntity, IRelationPredicateBucket filterBucket) at ScheduleDataService.DeleteSchedulesByCampaignID(IDataAccessAdapter Adapter, Int32 CampaignID) in D:\MyComapny\Projects\Media Center 3.5\MyComapny.MyProduct.DAL\MyComapny.MyProduct.DAL\ScheduleDataService.vb:line 72

Is there a way to used the typed signature to delete TargetPerHierarchy entries?

It seems if I pass in the string version of my entity names it works confused

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 20-Jun-2008 10:25:27   

Adapter.DeleteEntitiesDirectly(GetType(ScheduleEntity), New RelationPredicateBucket(ScheduleFields.CampaignID = CampaignID))

No parameterless constructor defined for this object.

at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)

There is no parameterless CTor for abstract entity class.

Please use the supertype's name.

Hint: you may control which types are deleted through type filters added to your RelationPredicateBucket object you pass to DeleteEntitiesDirectly().

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 20-Jun-2008 10:45:47   

It has to create an instance of the type to be able to do auditing etc. It performs a normal ctor construction call by using Activator.CreateInstance(), and if the type is an abstract entity, there's no public ctor so it can't instantiate an instance.

For these entities, either don't make the type abstract (if you use auditing etc.) or use the string based overload.

Frans Bouma | Lead developer LLBLGen Pro