This question is locked. New answers and comments are not allowed.
Hello,
I have a User class with a collection of User Group in it. When I delete the User, all the entries in the User Group should be deleted according to cascade delete. Please refer to the steps I followed.
Step 1 : The usergroup collection has ItemType property.
Step 2 : The app.config with User class details
Step 3: UserGroup with delete property
Step 4: When I fetch the User using orm collection and give delete it does not work.It runs into some loop and doesnt end.
Please advice me asap.
I have a User class with a collection of User Group in it. When I delete the User, all the entries in the User Group should be deleted according to cascade delete. Please refer to the steps I followed.
Step 1 : The usergroup collection has ItemType property.
public partial class User
{ [Telerik.OpenAccess.FieldAlias("groups")]
[Telerik.OpenAccess.ItemType(typeof(UserGroup))]
public IList<
UserGroup
> UserGroups
{
get { return groups; }
}
}
Step 2 : The app.config with User class details
<
class
name
=
"User"
>
<
field
name
=
"groups"
>
<
collection
>
<
extension
key
=
"inverse"
value
=
"user"
/>
<
extension
key
=
"managed"
value
=
"true"
/>
</
collection
>
</
field
>
<
extension
key
=
"db-optimistic-locking"
value
=
"changed"
/>
<
extension
key
=
"db-key-generator"
value
=
"AUTOINC"
/>
</
class
>
Step 3: UserGroup with delete property
<
class
name
=
"UserGroup"
>
<
extension
key
=
"db-key-generator"
value
=
"AUTOINC"
/>
<
extension
key
=
"delete-orphans"
value
=
"true"
/>
</
class
>
Step 4: When I fetch the User using orm collection and give delete it does not work.It runs into some loop and doesnt end.
User deleteUser = (from c in ObjectScope.Extent<
User
>()
where c.UserId == deleteUserId
select c).First<
User
>();
ObjectScope.Remove(deleteUser);
ObjectScope.Transaction.Commit();
Please advice me asap.