Delete Collections without fetching

Posts   
 
    
LordBauer
User
Posts: 9
Joined: 14-Apr-2008
# Posted on: 10-Mar-2009 09:58:23   

Hello,

I want to delete a Entity with his collection without fetching the collection.

Im using Template "adapter".

I have tried with UnitOfWork2 but there is no DeleteMulti.

Is there a way?

regards

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 10-Mar-2009 10:05:49   

Please use the DataAccessAdapter's method DeleteEntitiesDirectly() passing the appropriate filter.

LordBauer
User
Posts: 9
Joined: 14-Apr-2008
# Posted on: 10-Mar-2009 10:46:20   

Hello,

I need your help again.

I tried this:

bucket.PredicateExpression.AddWithAnd(new FieldCompareSetPredicate(TUserRolesFields.UserRoleId,null,
                TUserRoleRightsFields.UserRoleId, null,SetOperator.In,
                TUserRoleRightsFields.UserRoleId == userRolesEntity.UserRoleId)).
                AddWithAnd(TUserRolesFields.UserRoleId == userRolesEntity.UserRoleId) ;
    
    

            this.adapter.DeleteEntitiesDirectly(typeof(TUserRolesEntity),bucket);

but i got this exception:

Eine nicht behandelte Ausnahme des Typs 'SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException' ist in sd.llblgen.pro.ormsupportclasses.net11.dll aufgetreten.

Zusätzliche Informationen: An exception was caught during the execution of an action query: The DELETE statement conflicted with the REFERENCE constraint "FK_UserRoleRights_URID". The conflict occurred in database "3107", table "dbo.T_UserRoleRights", column 'UserRoleID'. The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.

Can you help me?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 10-Mar-2009 20:51:42   

It's a referential integrity error raised by your DB. Something in your T_UserRoleRights table is referencing the table you are trying to delete from, and you do not have Cascade Delete set on the relationship.

Either delete the dependant records from T_UserRoleRights first, or modify the relationship to CascadeDelete.

Matt