Programming
Check if a Value is Present in Multiple Lists
If you have 2 (or more) lists in C# and you want to check if they have 1 or more values in common then you can use the following LINQ to check.
If you have 2 (or more) lists in C# and you want to check if they have 1 or more values in common then you can use the following LINQ to check.
If you have 2 dictionaries of the same datatype in C# which you want to merge together then you can use the following code. If a key exists in both of the dictionaries then the primary value will overwite the secondary value. In the above example secondaryDictionary will now contain Read more…
If you have a complex table structure in SQL that you want to map into corresponding classes in your .NET Core project it might be easier to output the result of your SQL query as JSON and then deserialize the results to your object model rather than trying to map Read more…
I’ve been trying to figure out the best way to provide access to connections in my services via Dependency Injection (DI) for a while now. Typically I’ll pass the IConfiguration object through to the service using DI and then retrieve the connection string directly and create a new connection object Read more…
If you want to get a users username in a site that uses authentication then you can just use the User object and that will provide all claims associated with that user. However if you want to get the username for a user where they’re not required to authenticate first Read more…
I’ve used Azure Active Directory (AAD) authentication and authorization in a variety of Web Apps for logins, calling external APIs (e.g. Graph API) and authorizing site area access and while authentication is reasonably simple to get working authorization has always been a bit more confusing. This is fair enough as Read more…
OData is an open protocol for enabling interaction with a datasource in a standardised way via a RESTful API. Theoretically using OData in combination with Entity Framweork should provide a simple way of providing access to SQL (or other) data via API, this is indeed the case but setting things Read more…
Bootstrap Table is the best way I’ve found of adding additional functionality to HTML tables. One of the nice features about it is that it will load data from a URL if it’s provided in the correct JSON format which allows the data provision to be decoupled from the page Read more…
I’ve been working with OData recently and one thing that briefly stumped me was that the property names begin with @ and in an MVC view the @ symbol is used to indicate C# code so when I tried to reference a property in JavaScript the page then thought I Read more…
If you want to use Entity Framework to access pre-existing SQL tables (the database first approach) then providing they’re all keyed up correctly it’s possible to generate all the required classes and the DB context for them with just a few commands. First you need to install the following 3 Read more…