MacBook Pro Monterey and Catalina Crashes and Reboots overnight
Solution: This sounds crazy. But if you have Google Chrome Web Browser open and you're done for the night, close Google Chrome. If I leave Google Chrome open throughout the night, I will wake up to the Mac having crashed and rebooted.
.NET Linq OrderBy and/or ThenBy using String Property Name Dynamically
Original Reference from:
https://stackoverflow.com/questions/36298868/how-to-dynamically-order-by-certain-entity-properties-in-entity-framework-7-cor
Linq Extensions
This extension extends IQueryable and IOrderedQueryable for dynamic conditions and string name sorting
using System;
using System.Linq;
using System.Linq.Expressions;
public static class IQueryableExtensions
{
public static IQueryable<TSource> WhereIf<TSource>(
this IQueryable<TSource> source,
bool condition,
Func<IQueryable<TSource>, IQueryable<TSource>> branch)
{
return condition ? branch(source) : source;
}
public static IQueryable<TSource> IncludeIf<TSource>(
this IQueryable<TSource> source,
bool condition,
Func<IQueryable<TSource>, IQueryable<TSource>> branch)
{
return condition ? branch(source) : source;
}
public static IOrderedQueryable<T> OrderBy<T>(this
IQueryable<T> source, string propertyName, bool ascending = true)
{
if (ascending) return source.OrderBy(ToLambda<T>(propertyName));
return source.OrderByDescending(ToLambda<T>(propertyName));
}
public static IOrderedQueryable<T>
OrderByDescending<T>(this IQueryable<T> source, string
propertyName, bool ascending = true)
{
if (ascending) return source.OrderBy(ToLambda<T>(propertyName));
return source.OrderByDescending(ToLambda<T>(propertyName));
}
public static IOrderedQueryable<T> ThenBy<T>(this
IOrderedQueryable<T> source, string propertyName, bool ascending =
true)
{
if (ascending) return source.ThenBy(ToLambda<T>(propertyName));
return source.ThenByDescending(ToLambda<T>(propertyName));
}
public static IOrderedQueryable<T> ThenByDescending<T>(this
IOrderedQueryable<T> source, string propertyName, bool ascending =
true)
{
if (ascending) return source.ThenBy(ToLambda<T>(propertyName));
return source.ThenByDescending(ToLambda<T>(propertyName));
}
private static Expression<Func<T, object>> ToLambda<T>(string propertyName)
{
var parameter = Expression.Parameter(typeof(T));
var property = Expression.Property(parameter, propertyName);
return Expression.Lambda<Func<T, object>>(property, parameter);
}
}
ASP.NET Core appsettings.json with AzureAD Properties
Here are appsettings.json properties for configuration of AzureAD in ASP.NET Core
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "yourtenantdomain.onmicrosoft.com",
"ClientId": "{ClientId}",
"TenantId": "common",
"CallbackPath": "/signin-oidc", // defaults to /signin-oidc
"ClientSecret": "{YourSecret}",}
Additional Examples
https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2