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 System; | |
using System.Runtime.InteropServices; | |
public class C { | |
static void Main(string[] args) | |
{ | |
Console.WriteLine(RuntimeInformation.OSDescription); | |
Console.WriteLine(RuntimeInformation.ProcessArchitecture.ToString()); | |
Console.WriteLine(RuntimeInformation.FrameworkDescription); | |
} |
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.AspNetCore.Diagnostics; | |
using Microsoft.AspNetCore.Mvc; | |
using System.Net; | |
namespace Samples; | |
public class GlobalExceptionHandler(ILogger<GlobalExceptionHandler> logger) : IExceptionHandler | |
{ | |
public async ValueTask<bool> TryHandleAsync( | |
HttpContext httpContext, |
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.AspNetCore.Diagnostics; | |
namespace Samples; | |
public class GlobalExceptionHandler(ILogger<GlobalExceptionHandler> logger) : IExceptionHandler | |
{ | |
public ValueTask<bool> TryHandleAsync( | |
HttpContext httpContext, | |
Exception exception, | |
CancellationToken cancellationToken) |
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 BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Columns; | |
using BenchmarkDotNet.Configs; | |
using BenchmarkDotNet.Environments; | |
using BenchmarkDotNet.Jobs; | |
using BenchmarkDotNet.Reports; | |
[Config(typeof(Config))] | |
[HideColumns(Column.Job, Column.RatioSD, Column.AllocRatio)] | |
[MemoryDiagnoser] |
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 BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Columns; | |
using BenchmarkDotNet.Configs; | |
using BenchmarkDotNet.Environments; | |
using BenchmarkDotNet.Jobs; | |
using BenchmarkDotNet.Reports; | |
using BenchmarkDotNet.Running; | |
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); |
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 BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Columns; | |
using BenchmarkDotNet.Configs; | |
using BenchmarkDotNet.Environments; | |
using BenchmarkDotNet.Jobs; | |
using BenchmarkDotNet.Reports; | |
namespace Benchmarks | |
{ | |
[Config(typeof(Config))] |
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
namespace Microsoft.eShopWeb.Features.Orders; | |
[Route("order/my-orders")] | |
public class GetMyOrdersController(CatalogContext db) : Controller | |
{ | |
[HttpGet] | |
public async Task<IActionResult> MyOrders() | |
{ | |
var userName = User.Identity.Name; | |
var orders = await db.Orders |
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
;WITH TableSizes AS ( | |
SELECT | |
s.Name AS SchemaName, | |
t.NAME AS TableName, | |
p.rows AS RowCounts, | |
CAST(SUM(a.total_pages) * 8 / 1024.0 AS DECIMAL(10, 2)) AS TotalSpaceMB | |
FROM | |
sys.tables t | |
INNER JOIN | |
sys.indexes i ON t.OBJECT_ID = i.object_id |
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 BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Columns; | |
using BenchmarkDotNet.Configs; | |
using BenchmarkDotNet.Environments; | |
using BenchmarkDotNet.Jobs; | |
using BenchmarkDotNet.Reports; | |
namespace Benchmarks | |
{ | |
[Config(typeof(Config))] |
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 void ApplyGlobalFilters<TInterface>(this ModelBuilder modelBuilder, | |
Expression<Func<TInterface, | |
bool>> expression) | |
{ | |
foreach (var entityType in modelBuilder.Model.GetEntityTypes()) | |
{ | |
if (entityType.ClrType.GetInterface(typeof(TInterface).Name) != null) | |
{ | |
var newParam = Expression.Parameter(entityType.ClrType); |