So, we have many models with EntitySet<t> fields, and by default they all have associations like

[Association(PairTo = "Owner", OnTargetRemove = OnRemoveAction.Clear)]
[Field]
public EntitySet<RegFieldAuditLog> ChangedFields { get; set; }

and it seems to me, thats the proper default type for all Many-to-One fields.

I've seen none examples in real world when I needed Deny action on remove from EntitySet. Moreover, it makes me type more unneeded stuff in my code. Is it possible to make OnTargetRemove = OnRemoveAction.Clear to be the default action for this types of fields?

asked Feb 21 '11 at 10:18

xumix's gravatar image

xumix
425757682

edited Feb 21 '11 at 10:19


One Answer:

If the question is about your particular case, you can do this by implementing IModule.OnDefinitionsBuilt method. You should look for all the entity sets with this default and check the attribute there for the same value. If it isn't explicitly defined, change the value to your own default.

If the question is about DataObjects.Net default, I'm not so sure. I agree that most of entity sets are cleared with their owner's removal, but getting exception instead of implicit removal of items seems preferable (IMO, of course). At least, nothing unexpected will happen in this case.

answered Feb 21 '11 at 13:17

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

edited Feb 21 '11 at 13:17

I agree that most of entity sets are cleared with their owner's removal

What can be unexpected then? But, ok, at least, now I understand how to change the default behavior, thanks.

(Feb 21 '11 at 13:56) xumix xumix's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×52
×14
×12

Asked: Feb 21 '11 at 10:18

Seen: 3,283 times

Last updated: Feb 21 '11 at 13:56

powered by OSQA