Created
September 7, 2020 11:07
-
-
Save 0x414c49/16e22720162bd6b1b437372080970ca6 to your computer and use it in GitHub Desktop.
EF Core - Tag Queries with source information
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 DbContextExtensions | |
{ | |
public static IQueryable<T> TagWithSource<T>(this IQueryable<T> queryable, | |
string tag = "", | |
[CallerMemberName] string methodName = "", | |
[CallerFilePath] string sourceFilePath = "", | |
[CallerLineNumber] int line = 0) | |
{ | |
return queryable.TagWith(string.IsNullOrEmpty(tag) | |
? $"{methodName} - {sourceFilePath}:{line}" | |
: $"{tag}{Environment.NewLine}{methodName} - {sourceFilePath}:{line}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment