C#

C

C#

We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.

Join

Convert from MSSql to MySql

I'm trying to convert this MSDoc tutorial project from a local instance of MSSql to a MySql server. I'm fairly certain I've gotten all the configuration correct, except the syntax differences of MSSql to MySql. (i.e nvarchar) I pushed it to GitHub if someone is able to take a peek at it. Thanks in advance. https://github.com/Cykotech/RazorPagesMovie...

what are hashtags for in C#?

i've written C# for a month and have zero idea what these hashtag symbols are for. like #define - what does that do?

Need help

``` public static string CaesarTower(int n) { if (n < 1) { throw new ArgumentException();...

Code to Diagram (EF Core Power Tools) very beginner question

Hi, Tldr: How to show .dgml as graphic in Visual Studio 2022? Answer: Install DGML Editor from Visual Studio Setup....
No description

βœ… SDK 8.0.403: System.InvalidOperationException: No workload set information

I'm currently running into an issue that impacts all of my C# projects after an SDK update. I have tried to look for similar issues and haven't seen any that relate to this version. dotnet info posted in comments OS is OpenSUSE Tumbleweed RPM install ...

Intelisense unexpectedly broken in VisualStudio.

Don't know what happened but recently i am unable to build even fresh project from visual studio. It produces this ```NuGet package restore failed. Please see Error List window for detailed warnings and errors. Error occurred while restoring NuGet packages: NuGet.PackageManagement.VisualStudio.Exceptions.ProjectNotNominatedException: The operation failed as details for project Test2 could not be loaded. at NuGet.PackageManagement.VisualStudio.CpsPackageReferenceProject.GetPackageSpecsAndAdditionalMessagesAsync(DependencyGraphCacheContext context) at NuGet.PackageManagement.DependencyGraphRestoreUtility.<GetSolutionRestoreSpecAndAdditionalMessages>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown ---...

NuGet package project references

I need to share a project from my solution as a NuGet, to provide base implementation types for my application's plugin system. Let's call this project BasePlugin. BasePlugin has project dependencies that must be supplied with the produced NuGet package. I was able to configure that; the built nuspec file contains the required project references....

βœ… I'm looking for performance and load testing data on ConfigureAwait(false)

I cannot find any proper performance and load testing data on ConfigureAwait(false) for .NET 8 API's and azure functions. I want this info in order to make educated decision on using it.

βœ… FileNotFoundException: Could not load file or assembly. The system cannot find the file specified.

I'm modifying an application using AsmResolver and adding a new assembly into the module references, but for some reason .NET can't find the referenced assembly even though it's right there in the same folder as the one I'm editing. Attached is a minimum reproducible example, and a video showing what's wrong. I also tried editing the .deps.json file, since this guy https://discord.com/channels/143867839282020352/1288099229834805248/1288099229834805248 had success with that and a similar problem,...
No description

VS intellisence when building dotnet runtime locally

Hi! I cloned the "runtime" repo and followed the steps to setup my PC to build and test it locally. The build works but when I open some of the solution I have intellisence errors : Reference to type 'ValueType' claims it is defined in 'System.Runtime', but it could not be found Am I missing any setup ?...

Dapper Migrations

Hey, looking for tips around dapper and handling migrations / updates to domain entities. So can keep log of changes in the database and run SQL scripts r likewise to keep the database sync and allow other devs in team to sync their local databases. Basically to get the same concept as would with EF migrations. The team I’ve joined prefers Dapper for lightweight reasons and ability to control SQL ran on queries and such....

Looking for a logging solution

Working on ASP.NET program.
I have a lot of stuff i want to do for logging. First off i want to log every time an endpoint is accessed, who accessed it, when it was accessed what info was passed to the api and the datatype that the endpoint returned. Then there's all the stuff i see in the command line. i would also like to log this stuff....

EF Core - Intermediate table or Navigation Properties?

Hi everyone, A beginner question here. I’m working on a .NET project using Entity Framework Core and SQL Server. I have two entities, Organizations and Modules, where an organization can have multiple modules, and a module can belong to multiple organizations. I initially thought of creating an intermediate table OrganizationModules to handle this many-to-many relationship. My question is: With Entity Framework Core, do I still need to explicitly define this intermediate table, or can I just rely on navigation properties (ICollection<Module> in Organization and ICollection<Organization> in Module) and let EF Core handle the join table behind the scenes? ...

βœ… Any practical use to have an endpoint accessing an entity trough a non ID path variable?

Hello, I was browsing Bitly's API documentation, and saw that the endpoint trough which a link can be edited isn't done trough an Id path parameter. I have never seen something like this, what benefit can such a design have?...
No description

βœ… Razor page not updating properly

I'm going through the MS Docs tutorial on Razor pages and I'm adding the search feature. My main issue is that even though my query updates the model appropriately, the page itself does not change. I've also made sure to clear the cache in case that was the issue.
No description

Partial view not found in Razor Pages despite being in the correct location

I am looking to import a few partials into a page within the _Layout file. The _Layout file contains the following code: ```html...
No description

Many To Many relationship with cascading for both entities

Hello, I'm wanting my many to many relationship to cascade delete when either entity is deleted. My issue is I can only set one to DeleteBehaviour.Cascade at a time without it erroring. If I set both to cascade, it tells me an entity can't have multiple cascade paths. I'd like to be able to delete either Application or User and it auto delete their Followers relationship. Here is my code: ```cs builder.Entity<Application>(ent => {...

NUnit test class what has functions Step1,Step2,Step3...

So after each step you want to validated the mocked classes / the result of the StepN function. StepN only has sense if StepN-1 had run correctly. (For now I'm just talking about the ideal "good behavior" like testing for NotThrowException and not for TestThrowException")...

βœ… difference between internal and file access modifiers

the content on Microsoft Learn is a bit difficult to understand.