Ticket T569875
Visible to All Users

How to use map persistent properties to read-only columns

created 7 years ago

[DevExpress Support Team: CLONED FROM Q251721: How do I create a readonly property?]
Hi,

It has been 8 years, so I want to check if this is still the case.

It seems it is because I am experiencing the same issue - insert clause contains read-only property.

Since I am not comfortable writing Session descendant at current stage of application just to remove a property from insert query that never should have been there in the first place - I would like to ask if there is another way to accomplish this?

I understand private persistent fields can be used to initialize values inside object itself and persisted to database, but that can be accomplished in other ways as well - for instance creating regular property and setting UI elements as read-only.

However, putting such fields in update/insert excludes other important usage - having database generated property which we only want to show in application.
Using private persistent field exposed through public read-only property seems like a perfect fit, but unusable because those fields ends up in update/insert query which then throws database errors.

Regards,
Mario

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 7 years ago (modified 7 years ago)

    Hi Mario,

    Thank you for contacting us. Read-only persistent properties are not yet supported out of the box. The solution described in this ticket is the easiest way to implement this functionality in the current version.

    Since it is not possible to determine whether or not a column in the database is read-only, a developer should somehow mark a property to indicate that it should not be included into the UPDATE query. As fart as I understand, overriding the GetPropertiesListForUpdateInsert method is inconvenient for you from the code maintenance point of view. Perhaps, you would like to mark such properties using attributes. If this solution meets your requirements, let me know. I will research the possibility of extending the example provided in the Q251721 ticket with this capability. Note that this solution will also require using a custom Session descendant.

      Comments (2)

        Dear, I am facing the same problem. I like to exclude fields from updating.
        Would you be so kind to provide a vb.net example and if possible with XPO ORM Designer created due to the fact that I am not able to create the cursom Atribute ExcludefromUpdate by designer.

        TX a lot!

        Dennis Garavsky (DevExpress) 7 years ago

          Hello Chris,

          I've created a separate ticket on your behalf (T595039: Excluding fields from updating). It has been placed in our processing queue and will be answered shortly.

          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.