DX.Data.Xpo
26.1.3.41
See the version list below for details.
dotnet add package DX.Data.Xpo --version 26.1.3.41
NuGet\Install-Package DX.Data.Xpo -Version 26.1.3.41
<PackageReference Include="DX.Data.Xpo" Version="26.1.3.41" />
<PackageVersion Include="DX.Data.Xpo" Version="26.1.3.41" />
<PackageReference Include="DX.Data.Xpo" />
paket add DX.Data.Xpo --version 26.1.3.41
#r "nuget: DX.Data.Xpo, 26.1.3.41"
#:package DX.Data.Xpo@26.1.3.41
#addin nuget:?package=DX.Data.Xpo&version=26.1.3.41
#tool nuget:?package=DX.Data.Xpo&version=26.1.3.41
DX.Data.Xpo
XPO (DevExpress eXpressPersistent Objects) database configuration and the abstract IQueryableDataStore base class for the DTO pattern. This package contains no mapping implementation — pick DX.Data.Xpo.AutoMapper or DX.Data.Xpo.Mapster on top of it (or roll your own XPDataStore subclass with manual mapping).
Target frameworks: net462, net8.0, net9.0, net10.0
DevExpress dependency: DevExpress.Xpo 26.1.*
Behaviour changes in 26.1.3.41
XpoDatabaseno longer sets the process-wideXpoDefault.DataLayerimplicitly (up to 26.1.3.40 it did, but only withUpdateSchema = AutoCreateOption.DatabaseAndSchema, and to whichever database was created last). Opt in withXpoDatabaseOptions.SetAsXpoDefault = true.- Without a default data layer such code does not fail on reads: XPO falls back to a stub provider, so queries return no rows;
CommitChanges()throwsNotSupportedException("the stub database provider is currently used"). If queries throughnew UnitOfWork()/new Session()suddenly return nothing after upgrading, setSetAsXpoDefault = true.
Behaviour changes in 26.1.3.40
XPDataStore.UpdateAsyncwith a default key fails instead of inserting a new row.- Update/Store results contain every item, in input order (they held only inserted items), with values saved by
OnSavingcopied back. A failed result'sModeis the mode of the failing item. DeleteAsyncreturns a failed result instead of throwing for non-validation errors.- On a pooled (SQL) database
DeleteAsyncruns in a database level transaction on a connection of its own (ExplicitUnitOfWork). Overrideprotected virtual Task BeforeDeleteAsync(TDBModel dbModel, Session session)to do work just before each object is deleted; changes it flushes are rolled back if the delete fails. In-memory and caching data layers keep using a normalUnitOfWork. - Batch Update/Store/Delete load all keys in one query instead of one per item.
XpoDatabase.GetDataLayer(name)honours the name (and throws for an unknown one); first use of a name from several threads creates one data layer; in-memory stores are no longer wrapped in a connection pool;AddXpoUnitOfWork(connectionName)uses the named connection.XpoDefault.UseFastAccessors = falseis only applied on .NET Framework.GeoHaversinecriteria are correct for distances over about 6,670 km (they returned about 20,002 km).
Install
dotnet add package DX.Data.Xpo
XpoDatabase — connection & session management (XpoDatabase.cs)
public class XpoDatabaseOptions
{
public string Name { get; set; }
public string ConnectionString { get; set; }
public bool EnableCaching { get; set; }
public AutoCreateOption UpdateSchema { get; set; } = AutoCreateOption.None;
public bool SetAsXpoDefault { get; set; } = false; // also make it XpoDefault.DataLayer
}
public class XpoDatabase
{
public XpoDatabase(Action<XpoDatabaseOptions> configure);
public XpoDatabase(params XpoDatabaseOptions[] options); // multi-datalayer support
public Session GetSession();
public UnitOfWork GetUnitOfWork();
public void Execute(Action<Session> action);
public T Execute<T>(Func<Session, T> action);
public Task ExecuteAsync(Func<Session, Task> action);
public Task<T> ExecuteAsync<T>(Func<Session, Task<T>> action);
public static Session GetSession(string name);
public static UnitOfWork GetUnitOfWork(string name);
public static IDataLayer GetDataLayer(XpoDatabaseOptions options);
public IEnumerable<TDest> CloneCollection<TSource, TDest>(IEnumerable<TSource> source, XpoDatabase destination);
public TDest Clone<TSource, TDest>(TSource source, XpoDatabase destination);
}
XpoDatabase wraps DevExpress's IDataLayer creation so you don't have to hand-build connection strings and data layers yourself. It supports multiple named data layers in the same process — pass an array of XpoDatabaseOptions (each with its own Name) to register more than one database, then resolve sessions/units of work for a specific one via the static GetSession(name)/GetUnitOfWork(name) overloads. CreateDataLayer (internal) reads AutoCreateOption and the EnableCaching node straight off the connection string, so schema auto-update and second-level caching are configured the same way DevExpress's own tooling expects.
XpoDatabase does not touch XpoDefault.DataLayer unless you ask for it: set SetAsXpoDefault = true on the options of the database that code creating sessions without a data layer (new UnitOfWork(), new Session(), an XPCollection without a session) should use. It sets XpoDefault.DataLayer to that database's own data layer, whatever UpdateSchema is. XpoDefault.Session is set to null, so the default session cannot be picked up by accident.
Clone/CloneCollection do an object-graph copy of XPO persistent objects from one XpoDatabase into another — useful for seeding a test/staging database from production data without a full export/import round-trip.
Two constructor overloads that take a bare connectionName/simple parameters are marked [Obsolete] — use the Action<XpoDatabaseOptions> or XpoDatabaseOptions[]-based constructors going forward.
DI registration (XpoCoreExtensions.cs, #if NETSTANDARD2_1 || NETCOREAPP)
services.AddXpoDatabase(o =>
{
o.Name = "DefaultConnection";
o.ConnectionString = Configuration.GetConnectionString("DefaultConnection");
});
// or register several data layers at once:
services.AddXpoDatabases(
o => { o.Name = "Db1"; o.ConnectionString = "..."; },
o => { o.Name = "Db2"; o.ConnectionString = "..."; }
);
AddXpoUnitOfWork(connectionName) and the single-string-argument AddXpoDatabase(connectionName) overload are [Obsolete] — prefer the options-based registration above.
XPDataStore<TKey, TModel, TDBModel> — the abstract store base (XPDataStore.cs)
public abstract class XPDataStore<TKey, TModel, TDBModel> : IQueryableDataStore<TKey, TModel>, IDisposable
where TDBModel : XPBaseObject
{
protected XPDataStore(IDataLayer dataLayer, IValidator<TDBModel> validator);
public abstract IQueryable<T> Query<T>();
public IQueryable<TModel> Query();
protected abstract TModel GetByKey(TKey key);
protected abstract TDBModel ToDBModel(TModel model);
protected abstract TModel ToModel(TDBModel dbModel);
protected TDestination MapTo<TSource, TDestination>(TSource source);
public Task<TResult> TransactionalExecAsync<TResult>(Func<IDataLayer, UnitOfWork, Task<TResult>> action);
public Task<IDataResult<TKey, TModel>> StoreAsync(params TModel[] models); // Create/Update/Store via FluentValidation
public Task<IDataResult<TKey, TModel>> DeleteAsync(TKey key);
public Task<IDataResult<TKey, TModel>> DeleteAsync(TModel model);
}
This is the class every concrete XPO-backed store in the DXWeb family derives from — directly (if you write your own mapping in ToDBModel/ToModel) or through the XPAutoMapperStore/XPMapsterStore subclasses in the sibling mapper packages, which implement ToDBModel/ToModel/Query<T>() for you via AutoMapper or Mapster. StoreAsync runs FluentValidation against the constructor-supplied IValidator<TDBModel> before committing, and wraps the DevExpress UnitOfWork commit in TransactionalExecAsync so failures roll back cleanly. ThrowIfDisposed/ThrowIfNull/ThrowIfNullOrEmpty are protected guard helpers available to derived classes for consistent argument validation.
Minimal usage (writing your own mapping, no AutoMapper/Mapster)
public class CustomerStore : XPDataStore<int, CustomerDto, XpoCustomer>
{
public CustomerStore(IDataLayer dataLayer, IValidator<XpoCustomer> validator)
: base(dataLayer, validator) { }
public override IQueryable<T> Query<T>() => /* project XpoCustomer -> T yourself */;
protected override CustomerDto GetByKey(int key) => /* ... */;
protected override XpoCustomer ToDBModel(CustomerDto model) => /* ... */;
protected override CustomerDto ToModel(XpoCustomer dbModel) => /* ... */;
}
In practice, most consumers skip writing ToDBModel/ToModel/Query<T>() by hand and instead derive from XPAutoMapperStore/XPMapsterStore (see DX.Data.Xpo.AutoMapper / DX.Data.Xpo.Mapster), which implement those members via a configured IMapper.
Legacy types (kept for source compatibility)
IXPDataMapper<TKey, TModel, TXPOClass>(XpoInterfaces.cs) —[Obsolete]XPDataMapper<TKey, TModel, TXPOClass>(XPDataMapper.cs) —[Obsolete], superseded by the AutoMapper/Mapster store variants.
Notes
- This package has a genuine transitive DevExpress dependency (
DevExpress.Xpo) and is version-locked to the DXWeb release wave (26.1.3.x↔ DevExpress v26.1.3). - If you need MS Identity storage on top of XPO, see
DX.Data.Xpo.Identity(plus its.AutoMapper/.Mapstervariant). - If you're building an ASP.NET MVC 5
ASPxGridView, seeDX.Data.Xpo.Mvc.
See the root README for the full package list and DevExpress version alignment notes.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.6.2
- DevExpress.Xpo (>= 26.1.6)
- DX.Data (>= 26.1.3.37)
- DX.Utils (>= 26.1.3.42)
- FluentValidation (>= 9.5.4)
- System.Security.Cryptography.Xml (>= 8.0.5)
-
net10.0
- DevExpress.Xpo (>= 26.1.6)
- DX.Data (>= 26.1.3.37)
- DX.Utils (>= 26.1.3.42)
- FluentValidation (>= 12.2.0)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging (>= 10.0.14)
- System.Security.Cryptography.Xml (>= 8.0.5)
-
net8.0
- DevExpress.Xpo (>= 26.1.6)
- DX.Data (>= 26.1.3.37)
- DX.Utils (>= 26.1.3.42)
- FluentValidation (>= 12.2.0)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging (>= 10.0.14)
- System.Security.Cryptography.Xml (>= 8.0.5)
-
net9.0
- DevExpress.Xpo (>= 26.1.6)
- DX.Data (>= 26.1.3.37)
- DX.Utils (>= 26.1.3.42)
- FluentValidation (>= 12.2.0)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging (>= 10.0.14)
- System.Security.Cryptography.Xml (>= 8.0.5)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on DX.Data.Xpo:
| Package | Downloads |
|---|---|
|
DX.Data.Xpo.Identity
XPO Based abstract storage provider for ASP.NET Identity |
|
|
DX.Data.Xpo.Mvc
Several extension classes and methods on DevExpress MVC Controls, XPO and XPDataStore implementations. This package needs an active DevExpress ASP.NET license |
|
|
DX.Data.Xpo.AutoMapper
DX.Data.IDataStore implementation for use with XPO with FluentValidation and AutoMapper |
|
|
DX.Data.Xpo.Mapster
DX.Data.IDataStore implementation for use with XPO with FluentValidation and Mapster |
|
|
DX.Data.Xpo.Identity.Mapster
XPO Based storage provider for ASP.NET Identity with Mapster implementation |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 26.1.3.42 | 112 | 11/18/2026 |
| 26.1.3.41 | 109 | 11/5/2026 |
| 26.1.3.40 | 192 | 11/4/2026 |
| 26.1.3.39 | 260 | 10/26/2026 |
| 26.1.3.38 | 391 | 8/5/2026 |
| 26.1.3.37 | 306 | 7/31/2026 |
| 26.1.3.36 | 316 | 7/14/2026 |
| 25.2.3.35 | 246 | 4/7/2026 |
| 24.2.3.35 | 557 | 12/13/2024 |
| 24.1.6.35 | 402 | 9/25/2024 |
| 24.1.6.34 | 398 | 9/25/2024 |
| 23.2.3.34 | 313 | 9/24/2024 |
| 23.2.3.33 | 455 | 9/17/2024 |
| 23.2.3.32 | 342 | 9/17/2024 |
| 23.2.3.31 | 484 | 1/11/2024 |
| 23.2.3.24 | 391 | 12/19/2023 |
| 23.2.3.23 | 398 | 12/14/2023 |
| 23.1.3.22 | 1,021 | 6/16/2023 |
| 22.2.3.22 | 1,022 | 1/4/2023 |
| 22.1.6.22 | 744 | 11/29/2022 |
26.1.3.41: XpoDatabase no longer sets the process-wide XpoDefault.DataLayer implicitly (it did only with UpdateSchema = DatabaseAndSchema, and to whichever database was created last). New XpoDatabaseOptions.SetAsXpoDefault (default false) makes a database's own data layer the XpoDefault.DataLayer, whatever the schema option. Behaviour change: code that creates sessions without a data layer (new UnitOfWork(), new Session()) must opt in. Without a default data layer such code does not fail on reads: XPO falls back to a stub provider and queries return no rows, while CommitChanges() throws NotSupportedException (the stub database provider is currently used). If those queries return nothing after upgrading, set SetAsXpoDefault = true.
26.1.3.40: Bug fixes found by a new unit test suite (DX.Data.Xpo.Tests). Fixed: GeoHaversine criteria returned about 20,002 km for any distance over about 6,670 km (Min(1, x) compared as int); XPDataStore.UpdateAsync with a default key inserted a new row (now fails); Update/Store results only contained inserted items (now every item, in order, with values saved by OnSaving copied back); failures always reported DataMode.Create; DeleteAsync threw on non-validation errors (now a failed result); XpoDatabase.GetDataLayer(name) ignored its argument; concurrent first use of a data layer name created several data layers; in-memory stores were wrapped in a connection pool (each pooled connection an empty database); AddXpoUnitOfWork(connectionName) ignored the name. Performance: batch Update/Store/Delete load all keys in one query instead of one per item; new objects are created through a cached constructor delegate; XpoDefault.UseFastAccessors is only turned off on .NET Framework. New: DeleteAsync runs in a database level transaction on a connection of its own when the data layer is pooled (SQL databases), with a protected virtual BeforeDeleteAsync hook whose flushed work is rolled back with a failed delete. Behaviour changes: UpdateAsync with a default key fails; Update/Store results contain all items; a failed result's Mode can be Update; DeleteAsync returns failed results instead of throwing; GetDataLayer with an unknown name throws.
26.1.3.39: System.Security.Cryptography.Xml 8.0.4 -> 8.0.5: DevExpress.Xpo 26.1.6 asks for 8.0.5, so 8.0.4 was a downgrade (NU1605) that broke every fresh restore.
26.1.3.38: Override transitive System.Security.Cryptography.Xml 8.0.3 -> 8.0.4 (pulled in via DevExpress.Xpo)
to resolve NU1903 (GHSA-8q5v-6pqq-x66h, -cvvh-rhrc-wg4q, -g8r8-53c2-pm3f, -mmjf-rqrv-855v, -23rf-6693-g89p).
26.1.3.37: Added a README.md with technical documentation, now embedded in the package via PackageReadmeFile.
26.1.3.36: Upgrade to DevExpress v26.1.3
23.2.3.31: Data.DataStore plus Validator and Mapper have been moved and simplified into package DX.Data
BREAKING CHANGES:
Data base classes moved to DX.Data package
DX.Data package refactored to use FluentValidation with simplyfied validation logic
XPDataMapper replaced by either AutoMapper or Mapster implementations
23.2.3.23: Upgraded to .NET8 and DX v23.2.3 Dropped support for .NETStandard!
22.2.3.22: Upgraded to DX v22.2.3
22.1.6.22: Upgraded several packages incl DX v22.1.6
22.1.4.21: Bug fixed when saving the object.
Model class needs to be refreshed after a commit. Otherwise XPO OnSaving changes don't come back into model.
Since we don't want to change the Mapper signatures and keep the Model reference in tact, this is done through
CACHED reflection except for Collection and Array properties.
22.1.4.20: Upgrade from .NET Framework to 4.6.1 to 4.6.2
22.1.4.19: Upgrade to DX v22.1.4
21.2.8.19: IQuery Users properly implemented, DX Upgrade v21.2.8 and preparations for Blazor Identity Support
21.2.4.17: .NET 6.0 and DevExpress v21.2.3 upgrade
21.1.5.16: Upgrade to DX v21.1.5
20.1.7.15: Upgrade to DX v20.1.7. Validation issues fixed
20.1.3.14: Upgrade to DX v20.1.3
20.1.2.13-pre-20064: Upgrade to DX v20.1.2-pre-20064 and .NET preview 5
19.2.6.13: Bug fixed in overloaded method to get XpoDatabase instance with options object
19.2.6.12: DI Extensionmethod now uses an options object for initialisation. Other refactorings done as well
19.2.6.11: Upgrade to DX v19.2.6
19.2.5.11: Signature-change on IDataValidator<..>.Deleting(..)
19.2.5.10: XpoStore.Query() not abstract anymore
19.2.5.9: dotnet standard v2.1 for dotnet core v3.1 support + upgrade to DX v19.2.5
19.2.4.7: Upgrade to DevExpress v19.2.4
19.1.5.7: Upgrade to DevExpress v19.1.5 and XPDataStore constructor uses interface types for mapper and validator
19.1.4.6: Upgrade to DevExpress v19.1.4
19.1.3.8: Fixes on DataMapper implementation
19.1.3.6: Upgrade to DevExpress v19.1.3
18.2.3.6: Small optimisations and upgrade to DevExpress v18.2.3
18.1.4.4: Refactorings to improve speed and support for Pageable (XP)DataStore
18.1.4.3: Abstract Generic DTO XPDataStore and XPValidator classes added
18.1.4.2: Better exception message on invalid connection string
18.1.4.1: Upgrade to DevExpress v18.1.4 and bug fixed on LockoutEndDateUtc.
17.2.6.2: Upgrade to DevExpress v17.2.6
17.2.5.2: DI Extension methods added and upgrade to DevExpress v17.2.5
17.2.4.2: Upgrade to DevExpress v17.2.4 and changed .NET Framework to v4.6.1
17.2.3.1: Initial dual mode package for .NET Framework and .NET Standard 2.0
Not operational on .NET Standard 2.0 yet