Thought I’d write a quick post to detail a few of the changes we’ve made to our XPO ORM Library in the v19.1 release cycle and a couple of changes we expect to make for our next major release (v19.2).
LINQ to XPO
- XPQuery now supports the SelectMany(collectionSelector, resultSelector) overload with two arguments - this simplifies LINQ queries for collections, especially many-to-many associations (v19.2). In certain instance, it helps completely eliminate the need for the Join method. Examples:
new XPQuery<Test>() .Where(c => c.Name == "2") .OrderBy(c => c.Oid) .SelectMany(c => c.ManyToManyCollection, (t, c) => new { Test = t, ManyToManyCollectionElement = c } ) .OrderBy(tc => tc.ManyToManyCollectionElement.SubName); //... new XPQuery<Test>() .Where(c => c.Name == "2") .OrderBy(c => c.Oid) .SelectMany(c => new XPQuery<TestRef>() .Where(w => w.Owner.Oid == c.Oid && w.Oid >= 0), (r, c) => new { Test = r, TestRef = c }) .Select(o => new { Name = o.Test.Name, SubName = o.TestRef.SubName } );
- XPQuery supports the new SelectDeleted option and is initialized with a Session-based constructor (v19.2). Examples:
unitOfWork.Query<Employee>() .SelectDeleted() .Where(e => e.Name == null).ToList(); new XPQuery<Employee>(unitOfWork) .SelectDeleted() .Where(e => e.Name == null).ToList();
- XPO throws a NotSupportedException when a non-persistent property is used in OrderByXXX or Where expressions (v19.1). You can still set the static DevExpress.Xpo.XPQueryBase.SuppressNonPersistentPropertiesCheck option to False to temporarily disable this behavior (not recommended).
New XPO Data Sources
- If using our XPBindingSource, XPInstantFeedbackView and XPServerModeView components in your WinForms and WPF projects (v19.1), we’d love to hear from you. For more information, see the following examples: WinForms Data Grid + XPBindingSource | WinForms Data Grid + XPInstantFeedbackView & XPServerModeView | WPF Data Grid + XPInstantFeedbackView & XPServerModeView.
- To help you get started with our new XPO data sources, we’ve integrated them into our Data Source Wizard (v19.2). The wizard is available for the DevExpress WinForms Data Grid and other visual components. We will update the WPF wizard as well..
ORM Data Model Designer
- The designer can now store connection string in the appsettings.json file of .NET Core projects (v19.2).
- You can now control whether to generate JSON serialization and Dependency Injection extensions for XPO in .NET Core apps (v19.2). These extensions are especially helpful for ASP.NET Core and Web API/OData apps.
- Of course, many other data model generation options are available within the designer:
- When a connection to a database fails, the wizard will display detailed error information and links so you can easily troubleshoot connection issues (v19.1).
- Important Note: Please beware of a Visual Studio issue that causes the ORMDataModel window to render transparently or black. As a workaround, uncheck Envrionment > General > Optimize rendering for screens in the IDE options and restart (T756731).
Love XPO and want to help us promote it? Add the package through Nuget.org instead of DevExpress Nuget!