DeleteEntitiesDirectly Exception: fieldsPersistenceInfo can't be null or empty.

Posts   
 
    
Posts: 98
Joined: 09-Feb-2005
# Posted on: 10-Jul-2006 00:48:51   

I'm having one entity type throw an exception when trying to delete it with this code:


        private List<string> Delete(List<string> entitiesToDelete)
        {
            List<string> deletedEntities = new List<string>();

            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                foreach (string entity in entitiesToDelete)
                {
                    try
                    {
                        adapter.DeleteEntitiesDirectly(entity, null);
                        deletedEntities.Add(entity);
                        _log.Info(entity);
                    }
                    catch (Exception ex)
                    {
                        _log.Info(entity + " ------------------ " + ex.ToString());
                    }
                }
                return deletedEntities;
            }
        }

The error message is this:

HelperNew - LookupIndustryScenarioEntity ------------------ System.ArgumentNullException: fieldsPersistenceInfo can't be null or empty. Parameter name: fieldsPersistenceInfo at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateDeleteDQ(IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, List1 pkFilters, IPredicate additionalDeleteFilter, IRelationCollection relationsToWalk) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.CreateDeleteDQ(IFieldPersistenceInfo[] fieldsPersistenceInfo, List1 pkFilters, IPredicate additionalDeleteFilter, IRelationCollection relationsToWalk) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.DeleteEntitiesDirectly(String entityName, IRelationPredicateBucket filterBucket) at sap.valuecollateral.tests.HelperNew.Delete(List`1 entitiesToDelete) in G:\My Documents\code\Work\sap\valuecollateral\website2005\trunk\tests\sap.valuecollateral.tests\HelperNew.cs:line 95

Using Adapter, llbl 2.0

The item dying on deletion is part of a TargetPerEntityHierarchy using an integer discriminator column. It is 2 levels, w/ the parent being LookupIndustry, and the 2 children being LookupIndustrySubSegment, and LookupIndustryScenario. It is only LookupIndustryScenario that is having difficulty w/ deletion, but there isn't much of a difference between the 2 classes. (Only 1 bit field that isn't part of any relations)

Any thoughts as to what this error means?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 10-Jul-2006 10:16:45   

So if you delete the other entities in the hierarchy, it is ok? Strange. I'll see if I can reproduce it.

Be aware that DeleteEntitiesDirectly with a hierarchy of TargetPerEntity isn't supported.

(edit): it is caused by the fact that the entity doesn't have any fields of its own: no field persistence info objects are known because there aren't any. Workaround: simply specify the supertype's name and not any of the subtypes and control which types are deleted through type filters added to your RelationPredicateBucket object you pass to DeleteEntitiesDirectly().

Frans Bouma | Lead developer LLBLGen Pro
Posts: 98
Joined: 09-Feb-2005
# Posted on: 10-Jul-2006 15:00:53   

Great. That'll work fine. Thanks.