Able to access Database without opening connection, using Dapper

So I have the following piece of code that is showing a strange behavior or I am missing some point here: public async Task<IEnumerable<MyData>> GetMyData() { MySqlConnection conn; IEnumerable<MyData> list; string querystring = "SELECT * FROM tbl_mydata;"; using (conn = new MySqlConnection(mydbconnectionString)) { //conn.Open(); ConnectionState check1 = conn.State; list = await conn.QueryAsync<MyData>(querystring, commandType: CommandType.Text); ConnectionState … Read more

Most efficient way to save a file on disk while executing async work, on a ASP.Net CORE Web Request

On a request on my Web API, I’m saving a image to the disk and also processing it with an external API which usually takes several seconds. This is a high traffic API, thus I would like to design it in the most efficient way. The image comes in Base64 “encoding”, but this is not pertinent. We can think about it as an arbitrary byte array of 150KB in average (so the saving to disk operation should be really fast).

Mocking HttpMessageHandler with moq – How do I get the contents of the request?

Is there a way to get the contents of the http request before deciding what kind of response I want to send back for the test? Multiple tests will use this class and each test will have multiple http requests. This code does not compile because the lambda is not async and there is an await in it. I’m new to async-await, so I’m not sure how to resolve this. I briefly considered having multiple TestHttpClientFactories, but that would mean duplicated code, so decided against it, if possible. Any help is appreciated.

System.ObjectDisposedException: Cannot access a disposed object, ASP.NET Core 3.1

I am writing an API using SignalR in ASP.NET Core 3.1. I am totally new to .NET Core, and am pretty new to SignalR too. I am having an issue executing MongoDB (Atlas) queries which are running in transactions. It appears that the transaction sessions are expiring before the queries are executing. I’m quite sure it’s a async/await issue, but don’t seem to be able to fix it.

Run async method regularly with specified interval

I need to publish some data to the service from the C# web application. The data itself is collected when user uses the application (a kind of usage statistics). I don’t want to send data to the service during each user’s request, I would rather collect the data in the app and send then all the data in a single request in a separate thread, that does not serve the users requests (I mean user does not have to wait for the request to be processed by the service). For this purpose I need a kind of JS’s setInterval analog – the launch of the function each X seconds to flush all collected data to the service.