As of May 31, 2023, we have updated our Code of Conduct.

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
44 views

Code structure for 3rd party API calls

The Problem: I need to create a HttpService (Interface + Implementation) within an application that will be responsible for communicating with an external API service. There are three types of data ...
Vedran Knezevic's user avatar
3 votes
3 answers
127 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
1k 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
180 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
78 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
254 views

Apply a schema validation against an HTTP request with JSON body

...
Cengiz Ergün's user avatar
3 votes
1 answer
140 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
0 votes
0 answers
91 views

Is there a better way to update the related data in Entity framework core 6.0.7?

Role Entity has multiple SkillRoleRequirement, Education & Experience ...
Mugil Karthikeyan's user avatar
1 vote
1 answer
539 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
196 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
326 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
0 votes
0 answers
177 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 ...
Rasik's user avatar
  • 101
3 votes
2 answers
125 views

RawSqlQuery minimizing risk of field name confusion

Is there a way to make the following code more maintainable? ...
Kirsten's user avatar
  • 423
3 votes
1 answer
172 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
0 votes
0 answers
751 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. ...
RileyDan's user avatar
  • 131
4 votes
1 answer
618 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
107 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
  • 699
0 votes
0 answers
256 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 ...
nop's user avatar
  • 699
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
  • 699
2 votes
1 answer
59 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
  • 699
1 vote
1 answer
103 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
  • 51
0 votes
2 answers
707 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
  • 51
2 votes
1 answer
471 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
  • 51
1 vote
2 answers
183 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
  • 165
1 vote
2 answers
1k 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
423 views

Execute .NET Core 3.1 background worker tasks simultaneously

I have following code: ...
leroy's user avatar
  • 13
0 votes
2 answers
255 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
95 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
59 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
716 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
116 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
5 votes
2 answers
2k 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
  • 161
7 votes
2 answers
3k 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
  • 699
1 vote
0 answers
513 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
8 votes
1 answer
2k 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
  • 1,989
3 votes
1 answer
9k 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,122
1 vote
0 answers
73 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
281 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
  • 418
1 vote
2 answers
133 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
121 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
2k 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
962 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
105 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
205 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
415 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
362 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
64 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
213 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
2 votes
0 answers
263 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
  • 121
5 votes
1 answer
11k 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