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

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 {
    // ...
    [FetchOnly]
    [Persistent("Total")]
    private double total;

    [PersistentAlias("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?

If you are an active Universal subscriber and would like to test this feature prior to the official release, download the DevExpress Universal v18.2 Preview installer. You can also use our https://nuget.devexpress.com/early-access/api Nuget package source.  Check the Include prerelease option when finding and installing the package:



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

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

25 July, 2018

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

Finally!

Now add geo spatial stuff please.

30 July, 2018

@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

Can't Wait!!!

ETA?

8 August, 2018

@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

Please login or register to post comments.