SqlAzureRecoveryStrategy for different SqlClients

Posts   
 
    
Findev
User
Posts: 103
Joined: 08-Dec-2014
# Posted on: 24-Aug-2020 09:58:56   

Hi,

Some weeks ago I've migrated the ORM projects to .net standard 2.0 and utilized the new Microsoft SqlClient. Had to update the invoking code's exception handling here and there to get rid of references to the old System SqlClient. New SqlClient is in-place replacement so the process was fairly simple, but then noticed a failing test, upon further investigation it was related to exception processing in a utility class: the exception in question was SqlException but coming the old client, which apparently was overlooked. Updated the namespaces and the issue was fixed.

For the ORM I can plug-in either version of the SqlClient, does provided SqlAzureRecoveryStrategy handle the differences under the hood?

from the v5.7.0 sources I can see that: \RuntimeLibraries\ORMSupportClasses\TransientErrorRecovery\SqlAzureRecoveryStrategy.cs uses reflection, thus I'd assume it does the job, however, the driver version uses the old references: \Drivers\SqlServer\SqlAzureRecoveryStrategy.cs if that has any relevance to the matter.

All in all, it works with either SqlClient and I don't have to think about it, right?

Thank you!

UPDATE: please change the topic title to "SqlAzureRecoveryStrategy for different SqlClients" simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39589
Joined: 17-Aug-2003
# Posted on: 24-Aug-2020 11:32:57   

Findev wrote:

Hi,

Some weeks ago I've migrated the ORM projects to .net standard 2.0 and utilized the new Microsoft SqlClient. Had to update the invoking code's exception handling here and there to get rid of references to the old System SqlClient. New SqlClient is in-place replacement so the process was fairly simple, but then noticed a failing test, upon further investigation it was related to exception processing in a utility class: the exception in question was SqlException but coming the old client, which apparently was overlooked. Updated the namespaces and the issue was fixed.

For the ORM I can plug-in either version of the SqlClient, does provided SqlAzureRecoveryStrategy handle the differences under the hood?

Yes. In 5.7 we refactored the runtime so it doesn't have a hard-reference to SqlClient for the azure recovery strategy class (we now use reflection). This wasn't a problem on netfx but on .net core people needed to add the sqlclient package which they sometimes forgot and with the new sqlclient it also didn't work properly.

from the v5.7.0 sources I can see that: \RuntimeLibraries\ORMSupportClasses\TransientErrorRecovery\SqlAzureRecoveryStrategy.cs uses reflection, thus I'd assume it does the job, however, the driver version uses the old references: \Drivers\SqlServer\SqlAzureRecoveryStrategy.cs if that has any relevance to the matter.

All in all, it works with either SqlClient and I don't have to think about it, right?

The driver uses System.Data.SqlClient as the designer runs on windows / netfx and we have no reason to switch to another sqlclient package for this, as the netfx one works well for what we need to do. Using the microsoft.data.sqlclient client with the driver would require extra steps from the user and for little gain here, so we left it as-is. In the future if we move the designer over to .net 5 we'll update this of course.

For your own code, it'll end up in the strategy used in the runtime which uses reflection and which will work with either client, so you don't have to do anything there simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Findev
User
Posts: 103
Joined: 08-Dec-2014
# Posted on: 24-Aug-2020 11:39:48   

[quotenick="Otis"]

Findev wrote:

Hi, For your own code, it'll end up in the strategy used in the runtime which uses reflection and which will work with either client, so you don't have to do anything there simple_smile

I had no doubts stuck_out_tongue_winking_eye