Print Page | Close Window

Cascading Delete Trouble

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=339
Printed Date: 03-Sep-2025 at 7:15am


Topic: Cascading Delete Trouble
Posted By: Darren
Subject: Cascading Delete Trouble
Date Posted: 30-Jul-2007 at 7:46am
I keep getting this error in my developer class when i go to delete a contact.
 
Me.Contact being the relation property between the parent and the child class.
 
 
here is the code:
 

Public Function DeleteGraph() As Integer

Dim numberOfItemsDeleted As Integer = 0

Dim contactDetails As EntityList(Of Model.Contact) = New EntityList(Of Model.Contact)(Me.Contact)

Dim contactDetailsCount As Integer = contactDetails.Count

Dim counter As Integer = 0

Do While counter < contactDetailsCount

contactDetails(0).Delete()

counter += 1

Loop

Me.Delete()

Return (contactDetailsCount + 1)

End Function

 



Replies:
Posted By: naveen.menon
Date Posted: 01-Aug-2007 at 3:29pm

new EntityList<T> only has 2 overloads.

1) new EntityList<T>()
2) new EntityList<T>(IEnumerable pCollection)
 
In your code, Me.Contact seems erroneous. Is that the line, your code breaks at?


Posted By: TrevLeyb
Date Posted: 01-Aug-2007 at 4:25pm

From looking at this (and without seeing what Me.Contact actually is), I would suggest that Me.Contact is an ENTITY and not an ENTITYLIST.

So you are trying to cast a ENTITY (singular) to a ENTITYLIST (plural) whcih would give the error you are reporting.
 
 


Posted By: Darren
Date Posted: 02-Aug-2007 at 3:33am

I got it sorted guys

The problem lay in my database schema , there was a relationship problem there.
 
I have a Matrix table linked to the contacts table.
The matrix holds 2 fields contactid and accountid
 
The contact table should have been the Parent and the Matrix the child , but i had it reversed
 
cheers



Print Page | Close Window