This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: http://www.blackbeltcoder.com/Articles/time/creating-a-user-friendly-timespan-string | |
public static class TimeSpanHelper | |
{ | |
/// <summary> | |
/// Constructs a user-friendly string for this TimeSpan instance. | |
/// </summary> | |
public static string ToUserFriendlyString(this TimeSpan span) | |
{ | |
const int DaysInYear = 365; | |
const int DaysInMonth = 30; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://stackoverflow.com/questions/30688909/how-to-get-primary-key-value-with-entity-framework-core | |
public static class DbContextKeyExtensions | |
{ | |
private static readonly ConcurrentDictionary<Type, IProperty[]> KeyPropertiesByEntityType = new ConcurrentDictionary<Type, IProperty[]>(); | |
public static string KeyValuesAsString(this EntityEntry entry) | |
{ | |
if (entry == null) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://stackoverflow.com/questions/30688909/how-to-get-primary-key-value-with-entity-framework-core | |
public static class DbContextKeyExtensions | |
{ | |
private static readonly ConcurrentDictionary<Type, IProperty[]> KeyPropertiesByEntityType = new ConcurrentDictionary<Type, IProperty[]>(); | |
public static string KeyValuesAsString(this EntityEntry entry) | |
{ | |
if (entry == null) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
${ | |
// Enable extension methods by adding using Typewriter.Extensions.* | |
using Typewriter.Extensions.Types; | |
Template(Settings settings) | |
{ | |
settings.OutputFilenameFactory = file => { | |
var firstClass = file.Classes.First(); | |
var positionOfLastModel = firstClass.Name.LastIndexOf("Model"); | |
var modelName = firstClass.Name.Substring(0, positionOfLastModel); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
${ | |
using Typewriter.Extensions.WebApi; | |
string ReturnType(Method m) | |
{ | |
if (m.Type.Name == "IHttpActionResult" || m.Type.Name == "IActionResult") | |
{ | |
return "void"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://wilsonhut.wordpress.com/2012/03/15/obvious-extension-methods-ienumerable-cache/ | |
public static class Extensions | |
{ | |
public static CachedEnumerable<T> Cache<T>(this IEnumerable<T> enumerable) | |
{ | |
return new CachedEnumerable<T>(enumerable); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @sourceServer varchar(100) | |
declare @destinationTable varchar(100) | |
declare @destinationTableSchema varchar(100) | |
declare @sourceQuery nvarchar(max) | |
set @sourceQuery = 'select-statement-that-gets-data' | |
set @destinationTableSchema = 'dbo' | |
set @destinationTable = 'destination-table-name' -- set table name here | |
-- Begin work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-ExplorerOptions -showHidenFilesFoldersDrives -showFileExtensions | |
Enable-RemoteDesktop | |
#cinst visualstudio2019enterprise -y | |
cinst vscode -y | |
cinst git -y | |
cinst git-credential-manager-for-windows -y | |
cinst fiddler -y | |
cinst paint.net -y | |
cinst terminals -y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Abstract class to use instead of an Enum class. | |
/// See https://lostechies.com/jimmybogard/2008/08/12/enumeration-classes/ for more information. | |
/// Also https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/microservice-ddd-cqrs-patterns/enumeration-classes-over-enum-types. | |
/// </summary> | |
/// <example> | |
/// public class MyEnumerationClass : Enumeration | |
/// { | |
/// private MyEnumerationClass(int value, string displayName, string customParameter) | |
/// : base(value, displayName) |