XPO - Easy Way to Map a Property to a Read-Only Database Column (v18.2)

XPO Team Blog
25 July 2018

With v18.2, eXpress Persistent Objects™ (XPO) includes additional community-driven feature - FetchOnlyAttribute. Applied to a class property or field, this attribute indicates that you can only read values from a database. XPO will not include these values in INSERT and UPDATE SQL statements.

public class MyClass : XPLiteObject {
    // ...
    private double total;

    public double Total {
        get { return total; }

You can also set the Fetch Only option in the Data Model Designer. In the metadata, the XPMemberInfo.IsFetchOnly property returns True for such members.

Typical scenarios

This attribute is helpful when you need to map XPO class properties to:

  1. Computed database columns: when it is inefficient to implement them as read-only using PersistentAliasAttribute.
  2. Auto-increment database columns that are not primary keys (for example, rowversion).

How can I test this feature today?

Everyone can use our https://nuget.devexpress.com/early-access/api Nuget package source - it's free.  Check the Include prerelease option when finding and installing the package:

If you are an active DevExpress Universal subscriber and would like to test this feature prior to its official release, please email our support team at support@devexpress.com or rather create a separate private ticket in the Support Center. With that, we can verify your account and provide you with DevExpress Universal v18.2 Preview installer privately.

If you are using a trial and want to use this feature today without Nuget, you can also purchase a DevExpress Universal license online (this will give you access to early builds such as this CTP via installers). If you own a non-Universal subscription and are ready to upgrade, email us at clientservices@devexpress.com for preferential upgrade pricing.

Please report any issues and suggestions in the Support Center once you've had an opportunity to try this new feature in your upgraded v18.2 project. By providing early build access, we hope to find out whether our new features and solutions address your requirements and issues. Your testing efforts and your feedback help us deliver the best possible final implementation. We have described other benefits of this cooperation in this post.

Interesting Support Center tickets

  • We improved the consistency between the InMemoryDataStore and other SQL database providers (T648223);
  • AddXpoDefaultUnitOfWork and other XPO extension methods for ASP.NET Core DI are not available in XPO for the full .NET Framework. This API is for the .NET Core/Standard 2.0 version only (T657285); 
  • We bypassed and reported a Mono bug in which a Xamarin app consumed a WCF XPO-based service (T639333); 
  • We discussed dynamic type usage with our recent example: How to implement a OData4 service with XPO (T654401);
  • This was originally an XAF-related topic. Two long-time customers jumped in and shared their XPO related experience and performance best practices (T653665);
  • A reminder that PersistentAttribute, NonPersistentAttribute and PersistentAliasAttribute are exclusive. Only one can be applied to an XPO member. In addition, there is NO NEED to explicitly mark readonly (getter only) properties with NonPersistentAttribute. Members without a public setter are treated as non-persistent automatically (from a private ticket).

Find more interesting customer questions and product enhancements for your favorite products in the DevExpress Support Center (expand the "Frameworks (XAF & XPO)" group on the right) and What's New documentation (see resolved issues).

Your feedback is needed!

What do you think about this XPO feature and the new "Interesting Support Center tickets" rubric in particular? Please let our team know in the comments.

Love XPO and want to help us promote it? Add the package through Nuget.org instead of DevExpress Nuget!

  Yekaterina K.
  Technical writer
  XPO team

Free DevExpress Products – Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We’ll be happy to follow-up.
Christian Wolff
Christian Wolff

Wonderful. Now we can use (Statistic-)Views and calculated Properties in the Database.

25 July 2018
Dennis (DevExpress)
Dennis Garavsky (DevExpress)

Christian, I appreciate your taking the time to follow up. My team and I are happy that this new v18.2 solution meets your needs better than the current solution (a custom UnitOfWork or Session descendant and the overridden GetPropertiesListForUpdateInsert method).

26 July 2018
Sigurd Decroos _
Sigurd Decroos _


Now add geo spatial stuff please.

30 July 2018
Dennis (DevExpress)
Dennis Garavsky (DevExpress)

@Sigurd: Would you please let us know how the existing solution works for you? I already asked this in community.devexpress.com/.../xpo-miscellaneous-updates-v18-1.aspx, but have not heard back from you.

We try to be fair and analyze many factors (not only request clarity and unique customer count). We distinguish things that customers can already do on their own from things that only we can do on our side. Scenarios that need XPO source change may be higher in our backlog than a scenario with a good workaround. Users also help us estimate the usability of existing solutions and improve them by providing feedback. They describe their real use-case scenarios, frequency, implementation costs and maintenance problems.

30 July 2018
Mysoft Systems
Mysoft Systems

Can't Wait!!!


8 August 2018
Dennis (DevExpress)
Dennis Garavsky (DevExpress)

@Mysoft Systems:

Around November time frame. If you cannot wait, please refer to the "How can I test this feature today?" section above.

8 August 2018
Clinton Dale
Clinton Dale

I just found this article.  I use SQLCLR to create some sophisticated functions that I can use on the SQL side, and I like to use computed (persistent) columns to populate very complex constructions from other fields in the row.  I will give this a shot.  I had to override a bunch of stuff to keep insert/update from trying to hit the field.

15 September 2018

Please login or register to post comments.