Is there a definitive naming convention for methods returning IAsyncEnumerable?

After C# 5 introduced the `async` and `await` model for asynchronous programming, the C# community arrived at a naming convention to add an "Async" suffix to methods returning an awaitable type, like ...

22 Dec at 06:51

Using Linq's Where/Select to filter out null and convert the type to non-nullable cannot be made into an extension method

Suppose I have ``` List<MyObject?> list = ...; ``` I want to turn it into `List<MyObject>`, but I have not been able to drop the nullable reference. Below is an MCVE. In my project I have nullable...

How to handle both a single item and an array for the same property using System.Text.Json?

I am trying to deserialize some JSON that contains a value that is sometimes an array, and sometimes a single item. How can I do this with [System.Text.Json](https://learn.microsoft.com/en-us/dotnet/...

20 Dec at 19:59

EF Core 3 DbQuery equivalent functionality

In ef core 2.2 I have used DbQuery to map raw sql results to object as following: ``` public partial class AppDbContext{ public DbQuery<SimpleQueryModel> SimpleQM {get;set;} } ``` and then ```...

Best practice for using Nullable Reference Types for DTOs

I have a DTO which is populated by reading from a DynamoDB table. Say it looks like this currently: ``` public class Item { public string Id { get; set; } // PK so technically cannot be null ...

Importing .proto files from another project

I have several contract projects that contains different protobuf files, but some of the message types have the same message type like I have now created a shared project and added an Address.proto fi...

5 May at 12:47

How do I Use ConfigurationBuilder in .net core 3.1 Winforms?

I have the following working in a .net core 2.1 aspnet application ``` using System; using System.IO; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Config...

20 Dec at 04:18

Entity Framework Core 3.0 - Lambda expression used inside Include is not valid

Here below I am using lambda expression in LINQ Includes for 1 level, to fetch a list of customers using three entities, the main one is for all Customers and has only 2 properties Id and bool: IsComp...

vcruntime140.dll 14.0 not compatible with PHP build

I have downloaded on a Windows Server 2016 machine. I have also downloaded and installed `vc_redist.x86.exe`. When I try and run `php-cgi` from the command prompt I get the following error: > PHP War...

27 Feb at 09:40

How to add all missing usings at once with Visual Studio 2019 and C#

When I write C#, I sometimes have 3-4 missing usings which I can add with the tooltip window -> add missing using, or doing ctrl + . On the line where a missing using is present. Doing this 3-4 times...

19 Dec at 17:11

Attempted to update or delete an entity that does not exist in the store

I am having a problem with EF Core 3.x and One-To-Many navigation properties which I did not have in previous versions. Consider the following code: In previous EF version, the following could be done...

What makes ValueTuple covariant?

This compiles correctly in C# 7.3 (Framework 4.8): ``` (string, string) s = ("a", "b"); (object, string) o = s; ``` I know that this is syntactic sugar for the following, which also compiles correc...

19 Dec at 14:7

System.MethodAccessException: 'Attempt by method 'Microsoft.Extensions.Logging.Configuration issue

In .NETCore, While running the application in `Program.cs` file at `CreateWebHostBuilder(args).Build().Run();` I'm getting the Exception > "System.MethodAccessException: 'Attempt by method 'Micr...

19 Dec at 07:2

How Do You Access the `applicationUrl` Property Found in launchSettings.json from Asp.NET Core 3.1 Startup class?

I am currently creating an Asp.NET Core 3.1 API Application. In it, I have a `launchSettings.json` that looks like the following: ``` { "iisSettings": { "windowsAuthentication": false, "an...

C# 8 base interface's default method invocation workaround

According to [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/default-interface-methods](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/prop...

18 Dec at 18:20

editorconfig - how to specify underscore prefix for readonly private fields?

I haven't been able to find anything on this online. Is there any way to specify that an underscore prefix for readonly private fields should be added? Ever since I started using an `editorconfig` f...

Generate NSwag client as part of the build

I have a project that uses NSwag to generate a client and the contracts from a swagger file. I don't want these generated files to be tracked by git, so that when the project is built on the build ser...

11 Sep at 11:18

Test Explorer (VS) shows '<Unknown project>'

Everthing below is made in VS2019, using .NET Framework 4.7 and NUnit + NUnit3TestAdapter I created an assembly called Exitus.Tests, and added a few unit tests. However, do to some issues with Nuget,...

18 Dec at 12:24

Allow anonymouos access to healthcheck endpoint when authentication fallback policy is set in ASP.NET Core 3

asp.net core 3 allows to set to make the endpoints secure by default: ``` services.AddAuthorization(options => { options.FallbackPolicy = new AuthorizationPolicyBuilder()...

Correct way to mutate a component property in blazor

I have two components, `Child.razor` and `Parent.razor`. The `Child.razor` HTML: ``` <input type="text" value="@Text" /> ``` The `Child.razor` C#: ``` [Parameter] public string Text { get; set; }...

17 Dec at 22:53

Include with FromSqlRaw and stored procedure in EF Core 3.1

So here's the deal - I am currently using EF Core 3.1 and let's say I have an entity: ``` public class Entity { public int Id { get; set; } public int AnotherEntityId { get; set; } publi...

OData on .Net Core doesn't return the right results on $select

I've added OData to my WebAPI project. Versions: 1. Core 3.1 2. OData 7.3.0 (beta version in order to work with Core 3.x) 3. EF Core 3.1.0 Here is my startup.cs ``` public class Startup { ...

18 Dec at 09:10

Best way to implement sort, search & pagination with Redis for maximum performance

I have large data approx 1,00,000 for employee. I have stored this data to one Redis key called "employess". Now there is one screen where I would like to perform search on some field & sort on each c...

19 Dec at 16:48

Convert IAsyncEnumerable to List

So in C#8 we got the addition of the `IAsyncEnumerable` interface. If we have a normal `IEnumerable` we can make a `List` or pretty much any other collection we want out of it. Thanks to Linq there....

What is @context and why is it red?

I'm using the `BlazoredTypeahead` component in a blazor server side app and I'd like to know where the @context keyword is coming from. The following code runs fine, but VS is reporting that it Cannot...

16 May at 18:29