Executing an Elastic Scale Multiple Shard Request in a Database Context

I am busy introducing new Elastic Scale technology in a project that I am currently working on. This technology, apparently, solves some complex problems that arise when developing a new fund of applications.

So far, the examples look great, and I'm busy implementing this in our newly created DAL.

For our application, we cannot rely solely on Elastic Scale in Azure. The application should also run on the same instance machine, including. So I created the following code to query a database that works quite well, also using Elastic Scale.

public IEnumerable<AnEntity> All() { var dbConnection = GetConnection(); using (var context = new OurDatabaseContext(dbConnection)) { var theEntities = context.EntityTable; return theEntities.ToArray(); } } private IDbConnection GetConnection() { var connectionInstance = connection[ConnectionStringNames.TheDatabase]; var dbConnection = connectionInstance.Create(); return dbConnection; } 

connectionInstance configured through an IoC that will create an IDbConnection that we can use in OurDatabaseContext . Everything is pretty simple.

The main problem I ran into was making a MultiShardConnection provided by Elastic Scale and implemented in the examples.

So my question is: is it possible to use MultiShardConnection with a database context (e.g. LINQ2SQL (which we use) or EF).

If not, is the only solution to use MultiShardConnection in conjunction with MultiShardCommand ? Or when will this feature become available?

+6
source share
1 answer

As I already know, there is no trivial way to make a multitask connection with dbContext.

Using MultiShardConnection + MultiShardCommand is quite simple from the examples. However, not all available methods are available (for example, ReadAsync).

BUT, I think that most interconnects can be circumvented using the right Sharding Key (display key). I solved the problem by adding another Sharding key to my ShardMapManager. If you want to describe your specific reason, you will need MultiShard Connection and poorly edit my post. There is always the possibility of creating multiple dbContexts.

+1
source

Source: https://habr.com/ru/post/979792/


All Articles