jonwagner / Insight.Database

Fast, lightweight .NET micro-ORM
Other
861 stars 145 forks source link

ReliableConnection and Azure Cloud Databases not working with AsParallel and Auto Interface Implementation #479

Closed keerthirajap closed 1 year ago

keerthirajap commented 2 years ago

ReliableConnection and Azure Cloud Databases retry logic not working with AsParallel and Auto Interface Implementation

Startup.cs file

` public class Startup { public void ConfigureServices(IServiceCollection services) { var strategy = new RetryStrategy();

        strategy.MaxRetryCount = 5;
        strategy.MinBackOff = new TimeSpan(0, 0, 0, 0, 100); // 100 ms
        strategy.MaxBackOff = new TimeSpan(0, 0, 0, 1, 0); // 1 s
        strategy.IncrementalBackOff = new TimeSpan(0, 0, 0, 0, 100); // 100 ms

        strategy.Retrying += (sender, re) =>
        {
            this._logger.LogWarning("Retrying. Attempt {0}", re.Attempt);
        };

        string sqlConnectionString = this.Configuration["DatabaseSetting:SqlDbConnection"];

        var sqlConnection = new ReliableConnection<SqlConnection>(sqlConnectionString, strategy);

        services.AddTransient(b => sqlConnection.AsParallel<IUserRepository>());
    }

} `

IUserRepository.cs

` public interface IUserRepository {

    [Sql(@"[dbo].[P_GetUserInfo]")]
    Task<UserInfo> GetUserInfoAsync(long userId);      
}

`

UserController.cs

public class UserController : ControllerBase { public UserController(IUserRepository userRepository) { this._userRepository = userRepository; } }

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

keerthirajap commented 2 years ago

Any updates?

Jaxelr commented 2 years ago

Hi @keerthirajap in my case I've been swamped with my day job, so ive had no bandwidth to take a look, I see you posted a snippet, but do you have a repro prj where we could emulate the behavior?

keerthirajap commented 2 years ago

Will create a repo and get back to you.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Jaxelr commented 1 year ago

Feel free to reopen if you manage to generate a repro.