Questions tagged [.net-core]

.NET Core is a lean, composable and cross-platform framework for building web and cloud applications. It is fully open source and available on GitHub (https://github.com/dotnet/core). Applications in .NET Core can be run and/or hosted on Linux and MacOS under .NET Core.

Filter by
Sorted by
Tagged with
2 votes
3 answers
230 views

C# Duplicated usage of an if/else condition and a ternary operator. A good practice?

I had a debate with a work mate regarding the following code as to which one of it would be the better practice: My code (in pseudo): var A = <precondition either TRUE or FALSE>; var B; if(A) { ...
  • 29
0 votes
0 answers
47 views

Service Bus Handlers Direct Access to DB vs Api

I have a dilemma on my service bus, whether to use an API (blue in the image) or Direct access to the database? (green in the image) Option A Use two api endpoints. First to get accounts to process. ...
  • 151
0 votes
1 answer
67 views

Good approach to design Business interface for versioned API?

I am designing an API using .NET core 6 C# which has 2 versions. For v1 I have something like the following for the business logic interface (fictional names and simple fields just to facilitate ...
  • 101
1 vote
0 answers
168 views

What design pattern does this implementation follow?

For a middleware solution I expose an API, which processes data and sends the necessary information to different parties. In the current design we create a new client, which acts sort of like an ...
-3 votes
3 answers
378 views

Can be logic around `List<T>.Enumerator._version` considered control flow exploitation?

List<T>.Enumerator “snapshots” list version upon creation by _version = list._version;. This allows enumerator to halt enumeration when List<T> changed during it. This behavior likely ...
  • 288
0 votes
0 answers
187 views

Microservice code reuse strategy for static classes

Hope this is the right place to post an opinion-based question like this. I'm in the process of converting an aging API monolith to a set of .NET 5/C#-based microservices and working on the code reuse ...
0 votes
0 answers
28 views

Synchronisation of db state in blazor

I have an app where certain data is stored in the database. Multiple users access the same set of data (similar of a collaboration tool). However, they can non deterministically work on stale data. ...
0 votes
1 answer
199 views

DDD+CQRS - Should I always check if the Databases are online?

I'm developing an intranet application and I'm trying to use some concepts from Domain Driven Design (DDD) and Command and Query Responsibility Segregation (CQRS) in .NET Core, with EFCore. But, to ...
0 votes
1 answer
70 views

Finding/determining future data for pricing

I'm honestly not even sure how to go about how to ask what I'm looking for/need. lol. I'm currently using Sql Server for my database and the 'new' .net 5. There are multiple pricing tables that each ...
  • 19
0 votes
1 answer
197 views

Processing large number of messages in a thread-safe manner

I have the following use case and would like to implement it in a thread-safe manner. Think of a Stack Overflow-like web application. Somebody upvotes a question. A new event is sent to the message ...
  • 767
2 votes
1 answer
392 views

Dependency injection post-serialization

I'm modeling a general RPG-game-style quest system where player choices lead to certain effects. The below examples have been simplified for the sake of clarity. This is a web-based context, which I ...
  • 40.6k
0 votes
2 answers
351 views

How to implement authorization in a microservices architecture?

I'm looking for a way to avoid centralized management of authorization rules. I'd like every microservice to be responsible for the authorization logic of its actions, but I'm having some trouble ...
8 votes
2 answers
6k views

Should appsettings.Development.json be added to the repository?

Lately I got in a discussion with my colleague whether the appsettings.Development.json should be added to the git repository or not. My considerations are: when a developer clones a repository to his ...
  • 382
-1 votes
1 answer
35 views

Are good practice to use SKPointI as key for dictionary

In my application I using SKPoinI as a key to store some small objects in Dictionary. SkiaSharp already used in this project for drawing and not need to be referred to only to allow SKPointI to be ...
1 vote
1 answer
79 views

How can I write integration tests if I need dynamically generated values from a javscript file?

We have a react website that, as part of it's process, loads a dynamically generated javascript file from a third party. It uses some of the scripts in this javascript file to generate values, which ...
1 vote
0 answers
95 views

How can I improve this API solution

Intro I'm creating an app and I'm not sure if the structure of the solution is correct. I have a BaseController that uses generics. This controller is inherited by others that do not have to ...
  • 19
1 vote
2 answers
655 views

Why it is possible to specify a value comparer for ImmutableDictionary<TKey, TValue>?

What is the intended usage of the ImmutableDictionary<TKey,TValue>.ValueComparer property? Why is it useful being able to compare dictionary values by using a specified equality semantic? I ...
1 vote
1 answer
238 views

Custom File System Index/Cache - How to save index

I've got an extremely oniony(deep) folder structure which contains Appx 1,000,000 text-based files on a network share. Using windows search is extremely slow and unreliable. I've created some text ...
  • 379
5 votes
4 answers
390 views

How to create a modular system of multiple .NET Core applications extending a single application?

So first of all let me explain what I want to achieve: I want to create a basic .NET Core console application which is responsible for loading external extensions (more on this later on), listening ...
0 votes
1 answer
171 views

Is it bad practice to mutate your HttpClient objects?

Im in the process of creating a base class for typed HttpClient services (yes, I'm utilizing IHttpClientFactory). I wrote the process in such a way that for each CRUD method invoked from the service, ...
  • 1,359
1 vote
3 answers
1k views

Why is it allowed to refer .net framework libraries in a .net standard library?

.Net Standard is specification. There are two popular implementation of the .net standard specification. ie .Net Core & .Net Framework When I create .Net Standard library, I am allowed to refer ...
-1 votes
2 answers
381 views

How to Mock NamedPipeClientStream

I created a class called MpvController to handle communication protocols over a .NET NamedPipeClientStream. Now, I need to test this controller. I have a second class named MpvControllerFactory that ...
0 votes
5 answers
300 views

How to force consumption of an object once it is created?

Use case: I need to create serial numbers that are accountable for, so serial number objects, once created must have a destination: either they are used (they get a code) or they are discarded. For ...
2 votes
2 answers
776 views

C#: Use Double Await Cause Issues?

We have Application service Method, which extracts data from SQL database using Entity Framework Core . Its Async method along with the Async Controller. Service: public async Task<IEnumerable<...
user avatar
0 votes
3 answers
407 views

When to set constants during DI setup and when expect them on the fly as parameters?

Let's assume you have a project (e.g. .NET Core) using dependency injection. A database repository relies on a database connection string. public abstract class BaseRepository { // use this when ...
1 vote
4 answers
1k views

Should you validate route parameters or let them fail with a 404?

So this is an example endpoint to fetch one user by its username [HttpGet("{username}")] public async Task<ActionResult<object>> GetUser([FromRoute] string username) { // ... ...
0 votes
0 answers
433 views

Net Core: Solutions to Update History Tables in Application Design

Our company did not properly design Address Record Code Module. Developers are updating Address SQL table with Multiple Service Methods, and are not updating AddressHistory Sql table. They're asking ...
user avatar
0 votes
1 answer
113 views

keep Controllers at one place or organize by domain

When creating a new .NET Core Web API the controllers will be put in the Controllers directory. I want to create request models for incoming requests (for validation purposes) and response models ...
2 votes
3 answers
358 views

How to clone an object graph and keep relationships of objects intact?

In my ASP.net core application with Angular 2+ client, I work with a complicated object graph. In the object graph I have some objects with references to each other. I have a simplification included ...
0 votes
1 answer
459 views

What's a good liveness probe for a Hangfire background job server?

We're in the process of moving everything to K8s and one of our applications is a small .NET Core 2.2 console app that runs a Hangfire background job server. At the moment the app runs as a Windows ...
  • 167
3 votes
0 answers
107 views

Technical architecture of platform on .Net Core

I'm designing a platform that will run robots developed by others. Basically anyone could implement a IAutonomousAgent and register the implementation on the platform. At runtime, the platform will ...
  • 364
0 votes
2 answers
832 views

Call API endpoint from API itself

I'm creating an .NET Core 3 API with Entity Framework. The data is from an existing database. Now I've the following situation: /persons -- get all the persons /companies -- get all the companies /...
  • 67
1 vote
2 answers
583 views

Is there still a place for non-async methods in Data Repository?

If we start a .NET Core 3.0 project today, which will use database connection (for example ASP.NET Core Web API), is there still a place for non-async operations while talking to the database? Or in ...
0 votes
0 answers
176 views

Registering dependency implemented in separate assembly with shared interfaces

Situation: I have a project with a Business Layer (WizBang.BL) that contains nearly all of my application logic. It communicates with a Data Layer (WizBang.Data) that contains by entity classes and ...
  • 101
15 votes
3 answers
25k views

How to justify using await instead of .Result() or .Wait() in .NET Core?

Since the inception of .NET Core, console apps, function apps, ASP.NET etc. are not using synchronization context in async methods (so they're synchronizing straight to Thread Pool). This means that ...
  • 259
-1 votes
1 answer
135 views

Dependency Injection and Factory resolution

In the below example, assume FooA and FooB each have constructors that have a large amount of dependencies being injected into them. If I have a class that needs to determine which IFoo ...
  • 227
1 vote
2 answers
407 views

Unit Testing Complicated Service Call with Many Methods

I am trying to understand principle of Unit testing, Purpose, and Moq. We have complicated Service Call. The Service Call encompasses numerous Repositories and Services, with dependencies and ...
-1 votes
1 answer
1k views

Should Specification Patterns return IEnumerable, IQueryable, or Expression?

We are implementing Specification Patterns with Domain Driven Design. Company architect also wants us to utilize Generic repository (not my choice). Currently require specification Pattern for Filter ...
1 vote
1 answer
2k views

Domain Driven Design: Should Specification Pattern exist in Repository or Application level for Paging?

In Domain Driven Design, should the specification pattern for paging/pagination exist on the Repository level or Application level, or another layer? Trying to see what Eric Evans author of DDD stated....
1 vote
1 answer
107 views

How to properly handle deployment configuration for Xamarin Forms app

We are currently working on a Xamarin Forms (.NET Core) application. We use Microsofts DevOps for the code repo, building and deployment. Since we want to test newly developed features in a safe ...
5 votes
3 answers
3k views

Why is it necessary for every new api to be async?

I'm expressing my frustration here somewhat, but why do many new libraries only have asynchronous APIs? For example I'm creating a small utility to fetch a web page and parse some data from it. ...
  • 270
0 votes
0 answers
68 views

How to send messages in the order they were queued, while ensuring that client B does not have to wait until client A has received his message?

I have a simplified producer/consumer pattern implemented below. The code outputs: "A" 1 second delay "B" 1 second delay "A" 1 second delay "B" ... What ...
-1 votes
2 answers
816 views

Hosting a standalone .Net Core Web Application

We've created a .Net Core Web Application and are deploying it as a stand-alone exe. The main reason for deploying it stand-alone was to not be dependent upon the version of .Net Core installed on the ...
0 votes
1 answer
81 views

A RESTful API for internal company system accessing peripheral devices

I am currently working on an internal storehouse management system for a certain company. They wanted it to be a web app so that they can use it without installation on any devices. We decided to ...
  • 13
1 vote
1 answer
490 views

Throttling the factory function of a Lazy<T> instantiated with LazyThreadSafetyMode.PublicationOnly

When you use the constructor of Lazy<T> requesting the valueFactory and mode parameters (I mean this one) you can specify LazyThreadSafetyMode.PublicationOnly. This way you can prevent the Lazy ...
5 votes
2 answers
2k views

C# extension methods design patterns and usage guidelines?

C# extension methods have seen a rise in usage over recent years. The offical microsoft guidelines on usage state: "In general, we recommend that you implement extension methods sparingly and only ...
  • 167
4 votes
1 answer
161 views

Architecture to lock account to mobile device

I'm currently creating a mobile app and have the following issue. I am required to only allow the user to login from a device that is registered to the users account. A user can have up to X number of ...
1 vote
4 answers
3k views

Service Oriented Architecture (SOA): One Database or Multiple Databases?

In Service Oriented Architecture (SOA), should there be One Single Database "with the share as much as possible philosophy" or Multiple Databases by Service/functional area? I know in Microservices, ...
0 votes
0 answers
172 views

Real-time application and RDBMS bottleneck

I'm currently developing a real-time application using .NET Core 2.2. Many IOT devices (could be up to 100) are concurrently sending messages via MQTT. These messages are parsed, elaborated to extract ...
1 vote
1 answer
769 views

Data entities in Onion Architecture

I'm trying to build a project using onion architecture (just a "Northwind"ish type app to get more up to speed with .NET Core). I also want to get a better grasp on Onion Architecture principals. I ...