Questions tagged [.net-core]

.NET Core is an open-source, modular implementation of the .NET Framework. It can be used in a wide variety of applications and verticals, ranging from servers and data centers to apps and devices. .NET Core is supported by Microsoft on Windows, Linux and macOS.

Filter by
Sorted by
Tagged with
0 votes
0 answers
79 views

Implementation of Strategy Pattern for Task Scheduler

I need to implement a feature that schedules notifications to a user to which a Task has been assigned. The schedule could be one-time or on a ...
user avatar
  • 101
3 votes
2 answers
109 views

RawSqlQuery minimizing risk of field name confusion

Is there a way to make the following code more maintainable? ...
user avatar
  • 423
3 votes
1 answer
61 views

EFCore Monitor Interceptor with logging queries

I created a SqlMonitorInterceptor that will check the execution time of queries and log errors. The main idea is to log queries in such a way that they can be easily copied into SQL Server Management ...
user avatar
  • 807
0 votes
0 answers
125 views

Is there a faster way to read bytes with a FileStream?

So I'm trying to read data and store it in an array as fast as possible and the fastest method I found of doing so was this. ...
user avatar
  • 119
4 votes
1 answer
142 views

Memory leak I can't identify using Bitmap and Graphics classes

I have some parallel.for one inside another. the last parallel.for have a normal for that ...
user avatar
2 votes
0 answers
43 views

Asynchronous TCP server refactor design & not working features

I'm working on an asynchronous TCP server which is supposed to be used for a chat. I want to get a review for the TCP server part because I'm struggling to find a good design to fulfill the following ...
user avatar
  • 423
0 votes
0 answers
77 views

Wrapper around SignalR's implementation

I made a web socket client wrapper using SignalR's implementation, but there are some downsides that I want to improve. CancellationToken's implementation is wrong/incomplete ...
user avatar
  • 423
2 votes
0 answers
343 views

High-performance ClientWebSocket wrapper

I'm working on a web socket client wrapper around ClientWebSocket and this is kinda my first public library project, which is why I'm asking this question here. I ...
user avatar
  • 423
2 votes
1 answer
48 views

Achieving same abstraction by replacing JObject's implementation with System.Text.Json alternative

I'm trying to improve this wrapper by replacing the Newtonsoft.Json with System.Text.Json in its ...
user avatar
  • 423
1 vote
1 answer
49 views

Reading inbox from a specific sender and for a specific subject in order to save excel attachments

In my .net core console application, I am reading a mail inbox and saving excel attachments from a specific sender that has a specific subject. It is working as is expected, I wonder if there are any ...
user avatar
  • 51
0 votes
2 answers
158 views

Sending emails from .net core console hostedservice

In my .net core hosted service console application, I am reading a database table, retrieving some values, and based on a status, I am sending emails. It is working as it is expected, I wonder if ...
user avatar
  • 51
2 votes
1 answer
91 views

Reading excel files and save data into database

In my .net core console application, I am reading multiple excel files and bulk copy data into a database table. It is working as it is expected, I wonder if there are any improvements to make it ...
user avatar
  • 51
1 vote
2 answers
162 views

Using a IEnumerable where we have mostly only one item

I have a project where I publish and subscribe some data packages. Mostly those data packages are just one package, but sometimes (1 in 100) there could be more packages at one time (a lot more, like ...
user avatar
  • 165
1 vote
2 answers
178 views

Configure service with user-related parameters in .NET Core dependency injection

I have service class which loads data from external service. This service needs API key which loads from db and unique for every user. ...
user avatar
  • 807
1 vote
1 answer
123 views

Execute .NET Core 3.1 background worker tasks simultaneously

I have following code: ...
user avatar
  • 13
0 votes
2 answers
85 views

How to replace the given email address with a value in a given input?

I have written the below method to replace some of the email domains like @gmail.com and @yahoo.com with a given text. ...
user avatar
3 votes
1 answer
66 views

Calling multiple clients from API controller methods?

Hi I have a requirement where in I have to call two different client methods from same api in .NET Core and I have structured my code as follows. THis is working fine but Please give me your ...
user avatar
0 votes
1 answer
47 views

Downloading multiple log files

This code succeeds in downloading log text files from multiple URLs. Can this be made more efficient? ...
user avatar
0 votes
0 answers
76 views

.net core console app read from external API and write into a database

I have a .net core console app that gets some data from an external API and inserts it into a SQL database table. It is working as expected but I wonder if you guys have any suggestions to make it ...
user avatar
  • 51
2 votes
0 answers
265 views

Read compressed XML file inside ZIP and parse data as fast as possible

I am trying to read and parse an XML file inside of a ZIP archive as fast as possible. The XML file is roughly 85GB in size, so I know for a fact that I/O also plays a role here, as I need to ...
user avatar
1 vote
0 answers
2k views

.NET Core Dependency Injection - Worker Service x Web Api [closed]

Folks, I have a big question about how .NET dependency injection "native/default" works on a Service Worker scope. We need to resolve a service(...
user avatar
  • 202
4 votes
1 answer
114 views

Updating items in a list from a blocking source asynchronously

This is a Windows forms application. this.Server.GetLogMessages() will block if there are no messages to get, so I want this in a separate thread. I'm putting the ...
user avatar
  • 270
5 votes
2 answers
1k views

Simple async task scheduler

I've written a .NET Core console application to monitor the operation of a sensor network and I'd like a review of the task scheduling performed by the main program loop. There are three tasks that ...
user avatar
  • 161
7 votes
2 answers
2k views

Decided to update HttpWebRequest to HttpClient

I updated my Instagram API and I read that HttpClient is now the preferred way in .NET Core 3.1. I would like to get a code review, because there are too many ...
user avatar
  • 423
1 vote
0 answers
221 views

Better way to Read /Write Memory<byte> to/from POCO

I am communicating with a machine that sends/received structured binary data to my netcore service. The machine supplier's new library uses Memory in their library's API. I have written the following ...
user avatar
8 votes
1 answer
935 views

Reading one source Stream by multiple consumers asynchronously

The problem was using single Stream from the HTTP response in multiple consumers simultaneously. For example: while data is loading, I want write it to the some ...
user avatar
  • 1,939
3 votes
1 answer
5k views

Example of why IReadOnlyList<T> is better than public List<T> { get; private set; }

Early today, I gave an answer to someone where I recommended using IReadOnlyList<T>. Then I was asked why not just use a private setter, e.g. ...
user avatar
  • 5,532
1 vote
0 answers
51 views

Avoiding Arrow Pattern with C# Pattern Matching [closed]

I have started to use C# 7's type based pattern matching. A method that only manages a single pattern-based result looks very clean and is easy to reason about. However, once a second pattern-based ...
user avatar
1 vote
0 answers
147 views

Find assemblies in subfolder of primary assembly

I'm using the following handler to resolve assemblies in a specifically named subfolder of the main assembly's folder. I am looking for improvements in: clarity correctedness flexibility, as long as ...
user avatar
  • 418
1 vote
2 answers
115 views

Building a Word document containing two different tables

I am trying to generate a Word document with two different tables inside it. For this purpose I have two similar methods where I am passing word document reference and data object and table to the ...
user avatar
  • 189
3 votes
1 answer
111 views

Writing a c# class that has enum like constraint while behaving like string

Following This post : https://stackoverflow.com/questions/630803/associating-enums-with-strings-in-c-sharp/56482413?noredirect=1#comment107635743_56482413 I wanted to go further as it didn't quite ...
user avatar
5 votes
1 answer
1k views

Random temp folder implementation for unit testing

I faced a series of problems when unit testing a tool of mine that generates files. They were caused by me putting the files in the same temporary folder and the tests running in parrallel. Here is ...
user avatar
4 votes
4 answers
664 views

Harry Potter Kata

I have implemented the Harry Potter Kata and I need your feedbacks. The rules are: A book costs 8 euros. There are 5 different volumes. To get a discount, you must buy books of different volumes: ...
user avatar
  • 145
3 votes
1 answer
71 views

Is this implementation of signed URLs reasonably secure?

I'm trying to implement signed URLs for short lived access to static files. The idea is: generate an URL with an expiration timestamp (e.g. ...
user avatar
3 votes
3 answers
152 views

Idiomatic F# for iterating a seq and mapping whenever changes occur on a given selection

I've written a function that takes a sequence and check for every item in that sequence whether the current value a selection (obtained with a selection function) is different (or on the first ...
user avatar
  • 1,101
2 votes
2 answers
285 views

C# - Reapply the manipulation of JS Object in .Net Core

IMPORTANT: I made another version with some improvements: Version 2 Since some months ago I disagree with the native/code methods to manipulate dynamic or ...
user avatar
  • 227
1 vote
1 answer
157 views

Three-way join in Entity Framework Core to retrieve all roles that a user has

I'm very new to Entity Framework Core, so I'm concerned about whether I've done this query in the most efficient way possible. The database I'm querying looks like this: Basically, ...
user avatar
0 votes
1 answer
62 views

Prioritizing one column over the other column of the same table [closed]

I am creating an API in .net core and I just could not figure out how to put the following Linq expression into a single call: ...
user avatar
  • 103
5 votes
1 answer
161 views

Car Showroom Database: Taking user inputs and manipulating arrays

I've been learning C# for around 2 weeks and I'm feeling a bit more confident. I wrote this for general practice and am quite proud but hoping to make it faster and more efficient as I progress and ...
user avatar
2 votes
0 answers
85 views

Generic search service to filter entries in lists

I'm in the process of implementing a fully generic service to filter out entries (of any type), which are contained in a ICollection. As it is generic, without any ...
user avatar
  • 121
5 votes
1 answer
8k views

Dependency Injected StackExchange.Redis Client

I am currently building cache for my application, and I would like to have my redis cache client work the same way you would dependency inject a DbContext. I am using StackExchange.Redis to manage my ...
user avatar
2 votes
1 answer
120 views

Vectorization, 7-bit encoding

I was curious how vectorization works and how to write suck code. To start simple I choose 7-bit encoding as my test suspect. I'm not expecting improved throughput in any way. My implementation works ...
user avatar
  • 23
3 votes
0 answers
996 views

C# Rest Client Benchmarking

I build a C# Rest Client library / framework. I noticed that it seemed to be significantly faster than RestSharp for GET at least. So, I decided to put together some benchmarks comparing it to other ...
user avatar
1 vote
1 answer
132 views

String Split a phrase into sentences

Hello this is a Console App(.Net Core) in Visual Studio 2019 and i am trying to split a string into sentences and then add them into a dictionary with Key the first word of the sentence and Value the ...
user avatar
5 votes
2 answers
143 views

NewSequentialId - pure net core 2.2 implementation of sql server function

i'm currently trying to rewrite sql server newSequentialId() function in pure c# that is performing as fast as possible and eats minimum memory. Question is can I it be done better - current ...
user avatar
4 votes
1 answer
97 views

Prime Number Table, i.e. List<int>

I have written many variations of the Sieve of Eratosthenses, which is the fastest way to generate a large collection of primes. (@slepic asked for clarification, which I provide in an answer below. ...
user avatar
  • 5,532
5 votes
0 answers
175 views

Using ClientFactory-pattern with Dependency Injection

I initially posted this on Stackoverflow but was recommended to try here instead. I'm looking for feedback on why the implementation of my ClientFactory is probably bad, from a Dependency Injection-...
user avatar
4 votes
1 answer
3k views

Dapper "async" and "await using"

I have been building my data access layer and performance is key for the project I am working on. I have chosen to use Dapper and dotnet core 3. I want to make use of the latest and greatest async ...
user avatar
3 votes
1 answer
140 views

ASP .NET Core DI: Dependency on single implementation of multiple registrations of service type

Problem I have a DI scenario where I have multiple classes that implement a common interface (IModelService). I'm using a generic framework class (...
user avatar
  • 139
3 votes
1 answer
80 views

Formatting a type's name

I'm writing a code generation library, I've exposed a couple of methods and of course in order to define a member you need to specify it's type, the easiest way is to use ...
user avatar
  • 8,418