Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
2 votes
1 answer
101 views

Simple priority task scheduler implementation

My project I am working on requires the following functionality for the processed messages: each message has a priority messages with higher priorities should have precedence over the ones with lower ...
Alexei's user avatar
  • 1,806
1 vote
2 answers
377 views

Thread-safe int wrapper in c#

My system is a .NET Core 7 console app, which starts some background threads. I need to pass some int values (counters, etc.) between the main and background ...
lonix's user avatar
  • 143
1 vote
2 answers
87 views

Refactoring duplicated installation code

I have the following classes: ...
cogumel0's user avatar
  • 181
4 votes
2 answers
135 views

Classes are using interface to send different messages to a console in C#

This is a follow-up of my thread in Class SettingView sending messages to a console in C#. Here is the whole project on GitHub. The starting point After attending ...
karwenzman's user avatar
1 vote
2 answers
184 views

Class `SettingView` sending messages to a console in C#

My challenge is to transfer examples from textbooks or videos into something I am coding on my own. Environment Visual Studio 2022 Net 7.0 ConsoleApp My goal My idea is to have a solution to provide ...
karwenzman's user avatar
3 votes
3 answers
574 views

Algorithm to find sequential ID gaps in List<long>

I had to develop an algorithm that will find gap between sequential Ids within a List<long>. For example as input we had the following ...
So_oP's user avatar
  • 131
2 votes
1 answer
4k views

HttpClient retry handler on response 429

When the remote server returns a 429 (Too Many Requests) response with the Retry-After header, the HttpClient can handle such cases with a handler: ...
sDima's user avatar
  • 849
4 votes
2 answers
223 views

Automating the process of determining which boxes to load on each flight for freight company

I was given a test assignment for the interview of the company and below is the code that I shared with them. I developed it using .NET 6 (Core) Console application. Actual problem statement: Coding ...
user19031158's user avatar
1 vote
1 answer
140 views

Azure DevOps Git: Fork into another Repo using Azure DevOps REST API

In my Azure DevOps Project, I have a Git repository that I would like to copy to another Azure DevOps Project. In other words, I should be able to copy the original repo into other Azure DevOps ...
Mugil Karthikeyan's user avatar
2 votes
2 answers
636 views

Apply a schema validation against an HTTP request with JSON body

...
Cengiz Ergün's user avatar
3 votes
1 answer
267 views

Export and import work items from Azure DevOps

I'm working on an application that exports and imports work items from Azure DevOps. To import work items into Azure DevOps, I have written the following code. Would you be able to review and make ...
Mugil Karthikeyan's user avatar
2 votes
1 answer
2k views

.Net Core 6.0 : Entity Framework - Either Or / Neither Nor / Both in Where clause

I am building a .Net Core 6.0 application that uses Entity Framework. I have situation where I need to apply the filter(Where clause) based on two properties (eg: Guid? skillType, string skillName). ...
Mugil Karthikeyan's user avatar
1 vote
0 answers
295 views

Update a gamer and its child objects using Entity framework 6.0 [closed]

The below logic is working fine. But is there any way to optimize this logic ? Gamer is the root level object, it will have Characters. Character will have set of Skills & a weapon I want to ...
Mugil Karthikeyan's user avatar
1 vote
0 answers
755 views

Hangfire context constructor injection

I tried following IHttpContextAccessor pattern but for Hangfire context. What I'm mostly interested in is CustomScope class with Resolve method. I'm using ActivatorUtilities there because otherwise I ...
Medo's user avatar
  • 111
3 votes
2 answers
152 views

RawSqlQuery minimizing risk of field name confusion

Is there a way to make the following code more maintainable? ...
Kirsten's user avatar
  • 433
3 votes
1 answer
345 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 ...
sDima's user avatar
  • 849
4 votes
1 answer
1k 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 ...
Bloodday's user avatar
  • 143
2 votes
0 answers
169 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 ...
nop's user avatar
  • 729
2 votes
0 answers
2k 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 ...
nop's user avatar
  • 729
2 votes
1 answer
68 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 ...
nop's user avatar
  • 729
1 vote
1 answer
213 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 ...
raysefo's user avatar
  • 197
0 votes
2 answers
1k 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 ...
raysefo's user avatar
  • 197
2 votes
1 answer
1k 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 ...
raysefo's user avatar
  • 197
1 vote
2 answers
197 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 ...
Max R.'s user avatar
  • 137
1 vote
2 answers
3k 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. ...
sDima's user avatar
  • 849
1 vote
1 answer
652 views

Execute .NET Core 3.1 background worker tasks simultaneously

I have following code: ...
leroy's user avatar
  • 13
0 votes
2 answers
577 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. ...
Vivek Nuna's user avatar
3 votes
1 answer
149 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 ...
chiru1983's user avatar
0 votes
1 answer
72 views

Downloading multiple log files

This code succeeds in downloading log text files from multiple URLs. Can this be made more efficient? ...
user1206480's user avatar
2 votes
0 answers
1k 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 ...
MortenMoulder's user avatar
4 votes
1 answer
158 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 ...
rhughes's user avatar
  • 270
6 votes
2 answers
3k 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 ...
PeterJ's user avatar
  • 171
7 votes
2 answers
5k 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 ...
nop's user avatar
  • 729
1 vote
0 answers
874 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 ...
Mark Lazarides's user avatar
9 votes
1 answer
3k 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 ...
aepot's user avatar
  • 2,019
3 votes
1 answer
12k 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. ...
Rick Davin's user avatar
  • 6,350
1 vote
0 answers
83 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 ...
PercyODI's user avatar
1 vote
0 answers
390 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 ...
Zev Spitz's user avatar
  • 438
1 vote
2 answers
149 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 ...
Glory Raj's user avatar
  • 189
3 votes
1 answer
127 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 ...
Lomithrani's user avatar
6 votes
1 answer
3k 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 ...
Etsitpab Nioliv's user avatar
4 votes
4 answers
1k 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: ...
ilyes's user avatar
  • 145
3 votes
1 answer
208 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. ...
Shoe Diamente's user avatar
3 votes
3 answers
343 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 ...
Natalie Perret's user avatar
2 votes
2 answers
495 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 ...
MiBol's user avatar
  • 237
1 vote
1 answer
878 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, ...
EJoshuaS - Stand with Ukraine's user avatar
0 votes
1 answer
65 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: ...
Vrankela's user avatar
  • 103
5 votes
1 answer
233 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 ...
cmills95's user avatar
1 vote
0 answers
442 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 ...
Philippe's user avatar
  • 111
5 votes
1 answer
14k 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 ...
Thorbear's user avatar