Hi,
ok theres not really such a thing as an "immutable" entity but there are entities which I prefer to treat as immutable. Mainly these are M2M entities (like a UserRole - User 2 Role).
I'm writing a user editing page at the moment and I thought to ask this. When editing an existing user I am fetching the user:
var users = from u in meta.User
where u.UserId == userid
select u;
users = users.WithPath(opath=>opath.Prefetch(p=>p.RoleCollectionViaUserRole));
var user = users.First();
In this scenario I am only allowing one role to be associated with the user but I always use the same design:
User.UserId - UserRole.UserId
UserRole.RoleId - Role.RoleId
So I can delete the existing UserRole entity like this (in a transaction):
adapter.DeleteEntity(user.UserRoleUsingUserId[0]);
user.UserRoleUsingUserId.Clear();
or
adapter.DeleteEntitiesDirectly(typeof(UserRoleEntity), new RelationPredicateBucket(UserRoleFields.UserId == user.UserId));
user.UserRoleUsingUserId.Clear();
and then I add a new one:
user.UserRoleUsingUserId.Add(new UserRoleEntity() { RoleId = Convert.ToInt32(RoleId.SelectedValue) });
then I save:
adapter.SaveEntity(user, true, true);
Now to my question, is there someway I can just mark the original UserRoleEntity for deletion without removing it from the collection and manually deleting it. As I am using the recurse feature of adapter.SaveEntity it'd be nice if in addition to recursing Inserts and Updates it could also do deletes.
(.Net 3.5, LLBL 2.6 Feb 6th Build, SQL 2005)