Created
June 14, 2022 17:55
-
-
Save WrackedFella/16ddc62203120c67abaec3f798b167ed to your computer and use it in GitHub Desktop.
This file contains 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
public static class UsefulExtensionMethods | |
{ | |
public static TModel FirstOrNew<TModel>(this IEnumerable<TModel> queryable) where TModel : new() | |
=> queryable.FirstOrDefault() ?? new TModel(); | |
public static async Task<TModel> FirstOrNewAsync<TModel>(this IQueryable<TModel> queryable) where TModel : new() | |
=> (await queryable.FirstOrDefaultAsync()) ?? new TModel(); | |
public static bool IsActuallTheSameAs(this string s1, string s2, StringComparison stringComparison = StringComparison.InvariantCultureIgnoreCase) | |
=> string.Equals(s1, s2, stringComparison); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment