eXpressApp Framework - Tips & Tricks (June 2020)

XAF Team Blog
02 July 2020

Time flies – we are already halfway through 2020. We certainly hope that you and your loved ones are doing well and staying safe.

Here is this month’s edition of XAF Tips & Tricks. Please let us know if you find the information below of value and tell us how we can improve this content going forward. If you have a support ticket you'd like to share with the XAF developer community, feel free to post a link in the comment section below.

Interesting Support Tickets

Resolved Issues

New and Updated KB Articles

Documentation Updates

XPO Query Parameter Validation

We softened default parameter validation in SELECT, UPDATE, and INSERT statements and introduced a new DevExpress.Xpo.DB.QueryParameterMode enumeration. You can set the ConnectionProviderSql.QueryParameterMode field or the ConnectionProviderSql.GlobalQueryParameterMode static field as needed.

using DevExpress.Xpo.DB;  
ConnectionProviderSql.GlobalQueryParameterMode = QueryParameterMode.Legacy; 

Unit and Functional Testing

We reworked and updated the Functional Tests (EasyTest) help section and added a new help topic to improve navigation between learning materials related to unit and functional testing.

FirstOrDefault Methods

The IObjectSpace interface includes the following new methods:

These methods mirror our FindObject<ObjectType>(CriteriaOperator) and FindObject<ObjectType>(CriteriaOperator, Boolean) methods, but accept a lambda expression as the first parameter.

// v20.1.4:
ObjectSpace.FirstOrDefault<Person>(p => p.FirstName == "Test");
// Older versions:
ObjectSpace.FindObject<Person>(CriteriaOperator.Parse("FirstName=?", "Test"));
ObjectSpace.FindObject<Person>(new BinaryOperator(nameof(Person.FirstName), "Test"));
ObjectSpace.FindObject<Person>(new OperandProperty(nameof(Person.FirstName)) == "Test");
ObjectSpace.GetObjectsQuery<Person>().Where(p => p.FirstName == "Test").FirstOrDefault();

LINQ may be more convenient than CriteriaOperator and more natural for Entity Framework users. XPO users may also like this shortcut.

Non-Persistent Objects

You can mark an Object Space as modified via the NonPersistentObjectSpace.AutoSetModifiedOnObjectChange property and the BaseObjectSpace.ModifiedChanging event. If you want to reset Object Space modified status once you've created a new object, use the NonPersistentObjectSpace.RemoveFromModifiedObjects method. See how to use these new APIs in the following examples:

Non-Persistent Object Enhancements

Our upcoming v20.1.5 release will offer the following enhancements to non-persistent objects.

  • NonPersistentObjectSpace will include a FindObject(Type, CriteriaOperator, Boolean) method overload. This method iterates objects loaded with GetObjects, GetObject, CreateObject (etc) methods, and returns the first object that matches the specified parameters.
  • NonPersistentObjectSpace supports custom fields (both calculated and non-calculated). You can create these in code and via the Model Editor (just as you would for persistent objects).
  • You can inherit the new NonPersistentBaseObject class instead of creating a Non-Persistent Object item from the Template Gallery.

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.
No Comments

Please login or register to post comments.