Answer by Simon_Weaver for Log event datetime with.Net Core Console logger
Visual Studio / .AddDebug() not showing timestampsIf you're in Visual Studio and needing timestamps on debug logs (eg. logs from EF Core showing SQL) the only option AFAIK (since AddDebug has no...
View ArticleAnswer by Simon_Weaver for How to get isolation level in EF for MSSQL?
In EF Core this works:System.Transactions.Transaction.Current.IsolationLevelIt's showing Serializable for me by default if I don't specify a level, and does show the updated value if I set it...
View ArticleAnswer by Simon_Weaver for Subscribing to Observable Input
Edit: This answer is mostly outdated now due to Angular signals.I'm really not a fan of passing an Observable as an @Input itself, but I'm a big fan of turning a standard @Input()into an Observable....
View ArticleSplit a collection into `n` parts with LINQ? [duplicate]
Is there a nice way to split a collection into n parts with LINQ?Not necessarily evenly of course.That is, I want to divide the collection into sub-collections, which each contains a subset of the...
View ArticleAnswer by Simon_Weaver for iisexpress.exe started crashing with Access...
StackOverflow, bad enum value, self referencing properties. All great possible triggers for this error but how to find WHERE!First of all forget IISExpress - that's just the 'messenger'.I disabled...
View ArticleComment by Simon_Weaver on Entity Framework query slow, but same SQL in...
PS. I have a Wifi 7 card in my laptop but an old router which otherwise is working just fine.
View ArticleAnswer by Simon_Weaver for Which is faster/best? SELECT * or SELECT column1,...
What's going on if SELECT * is FASTER than SELECT <column subset> ?(and everyone is telling you that's not possible!)So I ended up with a simple SELECT statement for a table with only a few dozen...
View ArticleComment by Simon_Weaver on What does the DBContext.Entry do?
Disclaimer: I'm actually using EF Core, which has this same method. I'm not able to verify EF 6 has this behavior.
View ArticleAnswer by Simon_Weaver for angular ngFor trackBy does not work as I expected
Edit: None of this answer has been updated since the new @for syntax came out. So some of the following may not still be relevant or be confusing if you're not familiar with the 'old way'. But in...
View ArticleAnswer by Simon_Weaver for Disable re-queueing of failed Hangfire BackgroundJob
Important if using DI container with an interface, you must put the attribute on the interface definition or it won't be recognized.public interface IDataUpdater{ [Hangfire.AutomaticRetry(Attempts = 0,...
View ArticleAnswer by Simon_Weaver for Losing Session State with ASP.NET/SQL Server
Another thing that can trip up session state is having the wrong domain set for httpCookies, so make sure you have the correct domain / subdomain.<system.web><httpCookies domain=".example.com"...
View ArticleAnswer by Simon_Weaver for How to display messages as list in gmail api?
For a newly created OAuth token - try waiting!I had a weird experience just now.I modified the example that shows labels to search messages but was getting an error:var messages = await...
View ArticleAnswer by Simon_Weaver for Set null as empty string value for input field
Note: This does work for number fields with a caveatCurrently the NumberValueAccessor (source) sets the value to null when the field is empty.However, be cautious of this issue...
View ArticleAnswer by Simon_Weaver for Can I hide the HTML5 number input’s spin box?
Important message of cautionWhen using a mouse with a scrollwheel, be aware that scrolling with the cursor hovering over a type=number textbox results in the number changing up or down.Now this may be...
View ArticleAnswer by Simon_Weaver for How to check if ios safari/chrome is in lockdown...
I'm using this:if (typeof window.FileReader === 'undefined'){ alert('Do you have Lockdown Mode enabled on your device?\n\nIf so you will need to add our website to the list of allowed sites to...
View ArticleAnswer by Simon_Weaver for Can't find variable: FileReader in Safari
This error can occur when using Lockdown mode - as FileReader is not available.
View ArticleAnswer by Simon_Weaver for Please run `npm cache clean`
A 'non corrupted global cache' is not the same as a 'non broken node_modules' for a particular project.Just got this when trying to run a simple Angular CLI command (Windows):An unhandled exception...
View ArticleHow to set context on an Angular [cdkPortalOutlet]
The Portal module in Angular Material (CDK) is a very powerful way to render dynamic content into a 'PortalOutlet'.A Portal<T> can be a TemplateRef where T is the type of the context...
View ArticleAnswer by Simon_Weaver for ERROR Error: No value accessor for form control...
Check for basic typos in the control you're using.I'm using signals, where item.selected is a Signal<boolean> and was getting the same error on the following code:<mat-checkout...
View ArticleComment by Simon_Weaver on How to create a FrozenDictionary from a static list
WARNING: If you've ever used the traditional ToDictionary() you've probably at some point come across a duplicate key exception. Important to note that ToFrozenDictionary does not raise an exception in...
View ArticleRun two async tasks in parallel and collect results in .NET 4.5
I've been trying for a while to get something I thought would be simple working with .NET 4.5I want to fire off two long running tasks at same time and collect the results in in the best C# 4.5 (RTM)...
View ArticleAnswer by Simon_Weaver for In Azure-devops, trying to create a drive using...
You can add -Scope Global to the parameters and it will then show in Windows Explorer or command line.
View ArticleAnswer by Simon_Weaver for TypeScript Type 'string' is not assignable to type
TypeScript 3.4 introduced the new 'const' assertionYou can now prevent literal types (e.g., 'orange' or 'red') being 'widened' to type string with a so-called const assertion.You will be able to do:let...
View ArticleAnswer by Simon_Weaver for TypeScript Type 'string' is not assignable to type
There are several situations that will give you this particular error. In the case of the OP, there was a value defined explicitly as a string. So I have to assume that maybe this came from a dropdown,...
View ArticleComment by Simon_Weaver on SQL Server JOIN missing NULL values
Frankly you can probably get away with '' instead of 'zzzz' for 99% of the time you find yourself needing to do something like this. Otherwise what you're saying is that an empty string is NOT...
View ArticleLooking for sample global.asax.cs files for routing information
No matter what you read about ASP.NET routing or REST I think the best way to learn more about them is to read other people's routing files. In a video with Jeff once you could catch a glimpse of the...
View ArticleComment by Simon_Weaver on StringFormat is ignored
I couldn't figure out anyway to get CommandParameter to recognize StringFormat so I had to do it with a custom MultiBinding where I would pass the constituent parts to the be formatted.
View ArticleComment by Simon_Weaver on URL to compose a message in Gmail (with full Gmail...
It's a huge shame that if the intended account isn't found that it fallback and in any case you can't see which account you're sending from. (Yes you can click on the 'To' area and see the 'From' but...
View ArticleComment by Simon_Weaver on Generics in C# - how can I create an instance of a...
this is still the best way?
View ArticleAnswer by Simon_Weaver for Angular update from 8 to 13 peer dependency problem
This problem can get very frustrating. I've spent a couple of hours trying to understand it and even created dummy angular 13 / 14 projects to see what the latest defaults are.My tip is don't forget...
View ArticleComment by Simon_Weaver on Why can't the C# constructor infer type?
BTW: It's important to realize the Factory class can have the same name as the results class, and if it's being used just as a factory you can make it static eg. public static class MyType. For my...
View ArticleComment by Simon_Weaver on how to exclude an attribute using model binding in...
You may also need [ValidateNever] - (look at the stacktrace for any validation related stack frames). But if you're trying to block based upon that, consider renaming the property to a method...
View ArticleAnswer by Simon_Weaver for Mandrill inbound: Reply mail not adding Metadata...
If you're using the .NET client you must use the AddMetadata method as opposed to just manually adding to the dictionary. How annoying - especially since the same doesn't seem true for Tags!//...
View ArticleComment by Simon_Weaver on Visual Studio freezes on breakpoints
How does this only have TWO answers after 13 years? And the problem still exists!
View ArticleAnswer by Simon_Weaver for Configure launchSettings.json for SSL in debug -...
You can also set the path to the pfx file in launchSettings like this.These are 'well known' environmental variable names.This is all you need to do.{"profiles": {"MyApp": {"commandName":...
View ArticleAnswer by Simon_Weaver for Does Dbcontext registered as "scoped" or...
If you've ever considering using Blazor, you need to consider scope even more carefully.Briefly, in Blazor you may find your DbContext is longer living 'by accident' because components are long living...
View ArticleAnswer by Simon_Weaver for Blazor onclick event is not triggered
Does your project include ASP.NET Core MVC?Warning: Do not put Blazor .razor components in /ViewsSo the component I was having issues with was originally a .cshtml page under...
View ArticleComment by Simon_Weaver on Is there any way to disable CSS Isolation in...
Why is it so difficult to understand that people want different things? Personally I want to disable it for .razor.css files that are used as CSS for emails, where I don't want the scoping to occur but...
View ArticleComment by Simon_Weaver on How to embed the scoped css bundle file generated...
Confirmed works with Blazor 9. I just added your code directly in no particular location in my csproj file.
View ArticleAnswer by Simon_Weaver for Where does MyApp.styles.css come from?
It’s CSS Isolation and the .css file is the result of bundling.https://learn.microsoft.com/en-us/aspnet/core/blazor/components/css-isolation?view=aspnetcore-9.0
View ArticleComment by Simon_Weaver on onParametersSetAsync is being called even though...
*VERY IMPORTANT: For this to work all your parameters must be primitive types. That means you cannot have an event handler since it is a complex delegate type - but otherwise still a parameter! Kind of...
View ArticleComment by Simon_Weaver on Executing method on Parameter change
Warning: You may not think you need to do this if your parameters are only primitive types, but if you have an event handler you will because it 'breaks' the diffing since the delegate isn't a...
View ArticleComment by Simon_Weaver on How does Blazor know when to look for a parameter...
Important Note: A event handler in a component is also subject to this diffing - after all it is just another [Parameter]. Logically, it makes sense to think of int and string as 'input' parameters and...
View Article