Click here to Skip to main content
13,355,335 members (69,095 online)
Rate this:
Please Sign up or sign in to vote.
I have a large, enterprise scale distributed application that I am working on.

I am using windows data-binding to generate data-bound forms for configuration quickly (in hours instead of weeks)

The entities that I am binding to implement INotifyPropertyChanged, and the data-binding has worked really well up to this point.

Due to changes in the specification and increasing row contention, I recently had to move from an optimistic locking model, to a pessimistic locking model.

As such, the entities are now "ReadOnly" by default, and in order to change property values, the entity must first obtain an exclusive lock on the record (which it does by a call to the server)

I tried implementing the IEditableObject interface, and in the BeginEdit() method I acquire the lock, and in the CancelEdit()/EndEdit() methods I release the lock.

This all works fine, except in the situation where a lock cannot be obtained (because another user has the same record locked)

If the time-out is exceeded while waiting for a lock, an ApplicationException is thrown out of the BeginEdit() method.

However, there doesn't seem to be any way to handle this exception, nor does there seem to be any way to communicate to the binding source that a particular entity is read-only.

I am considering implementing the ICustomTypeDescriptor interface, so that for a ReadOnly entity, I can yield property information that would return PropertyInfo.CanWrite as false.... but I am not sure if the windows binding framework will re-query this interface frequently enough.

There doesn't seem to be any support for Entities that might be in a read-only state.... (unless I have managed to miss it in the documentation???)

Any help, ideas, comments appreciated, specifically:

Is there an interface I can implement on the entity object that will communicate the read-only status of a record to the binding source, and subsequently set the bound controls to read-only (or not enabled)?

failing that,

How do you tell windows-forms-data-binding (BindingSource) that a particular record
is read-only?


Simon B.
Posted 31-Jan-13 19:23pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.180111.1 | Last Updated 1 Feb 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100