New Posts New Posts RSS Feed: Cascading Delete Trouble
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Cascading Delete Trouble

 Post Reply Post Reply
Author
Darren View Drop Down
Newbie
Newbie
Avatar

Joined: 06-Jul-2007
Location: United Kingdom
Posts: 23
Post Options Post Options   Quote Darren Quote  Post ReplyReply Direct Link To This Post Topic: Cascading Delete Trouble
    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

 
Back to Top
naveen.menon View Drop Down
Newbie
Newbie
Avatar

Joined: 09-Jul-2007
Location: United States
Posts: 5
Post Options Post Options   Quote naveen.menon Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
TrevLeyb View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Jun-2007
Location: New Zealand
Posts: 9
Post Options Post Options   Quote TrevLeyb Quote  Post ReplyReply Direct Link To This Post 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.
 
 
Back to Top
Darren View Drop Down
Newbie
Newbie
Avatar

Joined: 06-Jul-2007
Location: United Kingdom
Posts: 23
Post Options Post Options   Quote Darren Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down