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 Version FrameworkRuntimeVersion() | |
{ | |
var assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly; | |
var path = assembly.Location.Split(new[] { '/', '\\' }, | |
StringSplitOptions.RemoveEmptyEntries); | |
var index = Array.IndexOf(path, "Microsoft.NETCore.App"); | |
return new Version((index > 0 && index < path.Length - 2 ? path[index + 1] : null)!); | |
} |
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 class ElementContainer<T> | |
{ | |
public T? Value { get; set; } | |
public Index StartIndex { get; set; } | |
public Index EndIndex { get; set; } | |
public int Index { get; set; } | |
} |
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
using Microsoft.Data.SqlClient; | |
internal static class ProviderExtensions | |
{ | |
public static DateOnly GetDateOnly(this SqlDataReader reader, int index) | |
=> reader.GetFieldValue<DateOnly>(index); | |
public static async Task<DateOnly> GetDateOnlyAsync(this SqlDataReader reader, int index) | |
=> await reader.GetFieldValueAsync<DateOnly>(index); |
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
var statement = | |
""" | |
SELECT * | |
FROM dbo.Customers | |
WHERE ContactTypeIdentifier = 9 | |
"""; | |
using var context = new Context(); | |
var list = context.Customers.FromSqlRaw(statement) | |
.Include(c => c.Contact) | |
.ToList(); |
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
CREATE TABLE dbo.Taxpayers (Id INT IDENTITY PRIMARY KEY, | |
FullName NVARCHAR(100) NOT NULL, | |
Email NVARCHAR(100) NOT NULL, | |
Social VARCHAR(9) MASKED WITH (FUNCTION = 'partial(0,"XXXXX",4)') NOT NULL, | |
CreditCardNumber VARCHAR(16) MASKED WITH (FUNCTION = 'partial(0, "XXXX-XXXX-X-", 4)') NULL, | |
BirthDate DATE NOT NULL); |
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
DECLARE @BrokenTable TABLE (ID INT NOT NULL); | |
INSERT INTO @BrokenTable VALUES (1); | |
INSERT INTO @BrokenTable VALUES (3); | |
INSERT INTO @BrokenTable VALUES (5); | |
INSERT INTO @BrokenTable VALUES (7); | |
INSERT INTO @BrokenTable VALUES (9); | |
WITH CTE | |
AS (SELECT 1 AS Number | |
UNION ALL | |
SELECT Number + 1 |
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 Version FrameworkRuntimeVersion() | |
{ | |
var assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly; | |
var path = assembly.Location.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); | |
var index = Array.IndexOf(path, "Microsoft.NETCore.App"); | |
return new Version((index > 0 && index < path.Length - 2 ? path[index + 1] : null)!); | |
} |
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
static void Main(string[] args) | |
{ | |
int current = 20240403; | |
int birthDate = 19000924; | |
Console.WriteLine((current - birthDate).ToString()[..^4]); | |
Console.WriteLine((current - birthDate).ToString().RemoveLastCharacters()); |
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
DECLARE @sql NVARCHAR(MAX); | |
SELECT @sql | |
= ( SELECT ' UNION ALL | |
SELECT ' + +QUOTENAME(name, '''') | |
+ ' as DatabaseName, | |
s.name COLLATE DATABASE_DEFAULT | |
AS SchemaName, | |
t.name COLLATE DATABASE_DEFAULT as TableName | |
FROM ' + QUOTENAME(name) + '.sys.tables t |
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 interface ISample | |
{ | |
public void AcceptCallMethod(); | |
void CallerMethod() { } | |
} | |
public class Sample : ISample | |
{ | |
void ISample.AcceptCallMethod() | |
{ |
NewerOlder