1,623,888 questions
Advice
3
votes
6
replies
35
views
Implement an interface method with a type parameter
Suppose there's an interface
interface IAnimal {
IFood GetPreferredFood();
}
and a class
class Cat<F>(F food) : IAnimal where F : IFood {
private F _food = food;
public F ...
0
votes
1
answer
28
views
Postgres 23505 duplicate key exception in EF Core AddOrUpdate (race condition on initial insert)
I am encountering a duplicate key value violates unique constraint error in my ASP.NET Core application, and while I understand why it happens, I am unsure about the best practice to handle it using ...
-4
votes
0
answers
33
views
SQLite Error 10: 'disk I/O error' during EF Core migration in .NET MAUI (MacCatalyst) under low resource conditions
everyone!
The Problem: Some users are experiencing a crash loop during the application startup. The logs indicate a Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 10: 'disk I/O error'...
0
votes
1
answer
69
views
How to insert into a join table with a payload without causing an infinite loop?
I am getting what I believe is an infinite loop happening when I am trying to create view models from my model data, i.e. mapping them. The error I get is a 'stack overflow error'.
I believe the ...
1
vote
1
answer
84
views
Managing async Tasks when shutdown occurs in .NET apps
I have the following class called MessageSaver in a dll called MessageSaver.dll. This dll can be used by a .NET app for saving messages to a text file. The .NET app could be a Winforms app or a WPF ...
1
vote
1
answer
47
views
List<IFormFile> is null for large files
I have a C# Controller method that happily receives small files but when I try to upload a large file from the browser client, the "files" parameter is null.
I have searched the web and ...
-1
votes
0
answers
40
views
Modbus TCP connect failed
I tried to connect to my HMI by modbus TCP, but it threw a
System.IO.IOException: 'Unable to read data from the transport connection'
I previously connected to another HMI(BeiJer X2 base 7) using ...
1
vote
2
answers
52
views
Await and data integrity in concurrent scenarios
I finally found out the basic mechanism that C# uses to implement an async/await construct (using continuations). However, this led me to question data integrity. Imagine the following:
class ...
Advice
0
votes
4
replies
48
views
Query MongoDB using C#
I have never queried mongoDB before using C#, usually only things like SQL Server which seem more straight forward to me. I am also not an expert in C#, so please do not beat me up. Trying to learn.
I ...
Best practices
0
votes
2
replies
87
views
How to Clean Ugly Extension Methods
I want to clean this extension method (I am sorry for what you about to see, I am pretty shamed about this code 😅) but I have no I idea how to do it, so I am asking your help if you have any ideas of ...
Best practices
0
votes
2
replies
48
views
how to pass a WinRT array_view<> object to other WinRT class by reference, without creating a copy?
I have two C++/WinRT classes that are projected to C# (NET 8.0):
One implements an image decoding from a vendor's SDK in plan C++. Let's call it the producer, and the image data is presented in an ...
0
votes
1
answer
36
views
Cake script fails when importing Octopus Tools
I'm working on updating some older systems to slightly more modern code. I have a C# solution that was targeting .NET Framework 4.6.2, but is now on .NET Framework 4.8.1.
The solution builds fine in ...
-1
votes
0
answers
30
views
3D Object (ViewCube) in fixed on 2D ViewPort [closed]
I have a .NET Framework 4.8 application that shows a 3D object.
I would like to add a fixed Object that always stays in the top left corner, regardless of the move/rotate/zoom of the main model.
Does ...
0
votes
1
answer
72
views
ASP.NET Core Web API with repository pattern: how to get User.Identity in the repository class?
My ASP.NET Core Web API endpoint is used to get the data from a SQL Server database.
The controller calls the repository method, gets the instance of the domain class with the result from the database,...
2
votes
2
answers
153
views
How to make reusable linq statements, which can be included as part of a where, select and even order by clause
Imagine the following classes (much simplified version of the real use case):
public class Driver
{
public Int32 Id { get; set; }
public String Name { get; set; }
public String Country { ...