Ticket T503226
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

How to map a property to a read-only database column

XPO is "updating" Readonly Fields

created 8 years ago

Within the XPO ORM wizard, I set a data field to be readonly as I never want it to be updated by XPO, but want to the view data using XPO.  Yet when I create an xp object for a row in that table, make a change to other fields, and then save the record, XPO creates an update statement that includes updating the field I set as readonly.  This is not what I would have expected.  I expected that XPO to ignore readonly fields when creating an update statement for a row.  If this is by design, how else can I signal XPO, hopefully within the XPO ORM wizard, to not attempt to update a field that should be ReadOnly in the database.  Thanks!

Answers approved by DevExpress Support

created 7 years ago

We have added support for read-only database columns in XPO. If you would like to test this feature prior to the official 18.2 release, get the preview build in the How to map a property to a read-only database column ticket. Your feedback is welcome.

    Other Answers

    created 8 years ago (modified 7 years ago)

    Hello Jeff.

    Setting the Readonly property of a field in the designer makes it generate code for this field as described in the How to: Use Read-Only Persistent Properties article. This approach only makes it impossible to programmatically modify the property of the persistent object.

    If I understand your requirement correctly, you wish to prevent XPO from updating the database column mapped to a property. While XPO doesn't currently support this functionality out of the box, you can solve your task as described in the How to map a property to a calculated database column (implement a read-only persistent property) ticket.

      Comments (2)

        Thanks for steering me in the right direction.  I would strongly recommend that the ReadOnly property also prevents Xpo from including the field in the update statement.  It seems obvious that this should be the case.  But if not, simply add a builtin-in attribute to accomplish this.  What is weird is that such an obvious improvement to XPO has been ignored fro so many years.

        DevExpress Support Team 8 years ago

          Thank you for your feedback, Jeff.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.