Ticket T725838
Visible to All Users

Trying to avoid the exception: Connection Provider does not support the 'DevExpress.Xpo.DB.IDataStoreAsync' interface. in v19.1 CTP

created 6 years ago (modified 6 years ago)

[DevExpress Support Team: CLONED FROM T683644: FAQ: XPO Async/Await Method Support]
I'm having a bit of a problem.
I'm using WCF, and connection pooling, and SQL server depen dency notifications (and SQL provider descendant for CTE support).
Basically, everything available :)

Connection is made thus (DbSqlServerProvider is the name of MSSqlProvider descendant with CTE):

C#
public override IDataStore CreateDataStore(ConnectionInfo ci) { DbSqlServerProvider.Register(); var xpoConnectionString = ci.User.IsBlank() ? DbSqlServerProvider.GetConnectionString(ci.Server, ci.Database) : DbSqlServerProvider.GetConnectionString(ci.Server, ci.User, ci.Password, ci.Database); xpoConnectionString = String.Concat(xpoConnectionString, ";", "MultipleActiveResultSets=true"); var sqlParser = new ConnectionStringParser(xpoConnectionString); sqlParser.RemovePartByName(DbSqlServerProvider.XpoProviderTypeParameterName); var sqlConnectionString = sqlParser.GetConnectionString(); var sqlConnection = new SqlConnection(sqlConnectionString); var sqlStore = new DbSqlServerProvider(sqlConnection, AutoCreateOption.DatabaseAndSchema); DbEngine.FSPath = SqlClrAssembly.Check(sqlConnection); var poolConnectionString = XpoDefault.GetConnectionPoolString(xpoConnectionString); var poolStore = XpoDefault.GetConnectionProvider(poolConnectionString, AutoCreateOption.DatabaseAndSchema); var cacheConfiguration = new DataCacheConfiguration(DataCacheConfigurationCaching.NotInList); var objectsToDispose = new IDisposable[] { sqlConnection }; var root = MSSql2005SqlDependencyCacheRoot.CreateSqlDependencyCacheRoot(poolStore, sqlConnection, sqlStore, cacheConfiguration, out objectsToDispose); var node = new DataCacheNodeLocal(root) { MaxCacheLatency = TimeSpan.Zero }; node.ProcessCookie(DataCacheCookie.Empty); return node; }

So far, so good …
On the client, on the other side of the WCF code is:

C#
public override IDataStore CreateDataStore(ConnectionInfo ci) ... var client = new CachedDataStoreClient(binding, new EndpointAddress(uri)); ... var root = client as ICachedDataStore; var node = new DataCacheNode(root) { ... }; ... node.ProcessCookie(DataCacheCookie.Empty); return node; }

Actually, above is wrapped in 'XDataStoreWrapper' which just wrappes above node as IDataStore and adds some logging.

This worked until 19.1.
Now, under certain circumstances, I get the exception:

Your 'XDataStoreWrapper' Connection Provider does not support the 'DevExpress.Xpo.DB.IDataStoreAsync' interface. Please implement this interface, or use another compatible Connection Provider.

Now, I *cannot* forward implementation of IDataStoreAsync in wrapper as DataCacheNode (nor ICachedDataStore) do NOT implement it. So I basically wrote the following dummy wrappers:

C#
public sealed class XDataStoreWrapper : IDataStore, IDataStoreSchemaExplorer, ICommandChannel, ICachedDataStore, ICacheToCacheCommunicationCore, IDataStoreAsync, ... ... public IDataStore Store { get; } public XDataStoreWrapper(IDataStore nested) => Store = nested; ... ... public Task<ModificationResult> ModifyDataAsync(CancellationToken token, params ModificationStatement[] statements) => Store is IDataStoreAsync sa ? sa.ModifyDataAsync(token, statements) : Task.Factory.StartNew(() => Store.ModifyData(statements), token); public Task<SelectedData> SelectDataAsync(CancellationToken token, params SelectStatement[] statements) => Store is IDataStoreAsync sa ? sa.SelectDataAsync(token, statements) : Task.Factory.StartNew(() => Store.SelectData(statements), token); ... ...

… but it doesn't feel quite right.

Basically what I'm asking is since you provide class CachedDataStoreService (which implements ICachedDataStoreService), shouldn't there also be (say) CachedDataStoreServiceAsync implementing ICachedDataStoreServiceAsync.

Or am I missing something obvious?
--------------------

Actually, it seems I'm overcomplicating it.
Basically, I try to avoid the exception:

Connection Provider does not support the 'DevExpress.Xpo.DB.IDataStoreAsync' interface. Please implement this interface, or use another compatible Connection Provider.

So, I change this

C#
var client = new CachedDataStoreClient(binding, new EndpointAddress(uri)); var node = new DataCacheNode(client); return node;

… to this …

C#
var client = new CachedDataStoreClientAsync(binding, new EndpointAddress(uri)); var node = new DataCacheNode(client); return node;

But that doesn't seem to help, as ICachedDataStoreAsync which client implements is 'lost' when chaining to DataCacheNode?

--------------------------
So, is there something like DataCacheNodeAsync planned for 19.1 or should fallback to Task.Run substitues in IDataStore wrapper classes via Task.Factory.Start as above in the first post?

Answers approved by DevExpress Support

created 6 years ago (modified 6 years ago)

Hello Dusan,

DataCacheNode and DataCacheRoot do not support asynchronous operations. XPO provides a static flag to configure how XPO behaves in this scenario: DevExpress.Xpo.XpoDefault.DataStoreAsyncBehavior. In your case, it is safe to set this property to WrapIfNotSupported or WrapAlways.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.