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 User | |
{ | |
public Guid ID { get; set; } | |
[AlwaysUpper] | |
public string Firstname { get; set; } | |
[AlwaysUpper] | |
public string Lastname { get; set; } | |
public string EmailAddress { get; set; } | |
public string IdentityNumber { 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 ConverterExample.Converter; | |
using ConverterExample.Attribute; | |
using System.Linq; | |
using System.Reflection; | |
using Microsoft.EntityFrameworkCore; | |
using Microsoft.EntityFrameworkCore.Metadata; | |
using System; | |
namespace ConverterExample.Extension | |
{ |
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.EntityFrameworkCore.Storage.ValueConversion; | |
namespace ConverterExample.Converter | |
{ | |
internal sealed class UpperConverter : ValueConverter<string, string> | |
{ | |
public EncryptionConverter() : base (x => x.ToUpper(), x => x, 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
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] | |
public sealed class AlwaysUpperAttribute : System.Attribute | |
{ | |
} |
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 IF NOT EXISTS "encryptexample"."__EFMigrationsHistory" ( | |
"MigrationId" varchar(150) NOT NULL, | |
"ProductVersion" varchar(32) NOT NULL, | |
CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId") | |
); |
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
private static readonly string[] Cities = new[] | |
{ | |
"İstanbul", "Bursa", "Çankırı", "Konya", "Ardahan", "Ordu", "Giresun", "Adana", "Sivas", "İzmir" | |
}; | |
[HttpGet("getforecast/{id}")] | |
public IEnumerable<WeatherForecast> GetForecast(int id) | |
{ | |
List<WeatherForecast> weatherForecasts = new List<WeatherForecast>(); | |
var rng = new Random(); |
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 void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddControllers(); | |
services.AddOcelot().AddCacheManager(x => | |
{ | |
x.WithRedisConfiguration("redis", | |
config => | |
{ | |
config.WithAllowAdmin() |
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 IHostBuilder CreateHostBuilder(string[] args) => | |
Host.CreateDefaultBuilder(args) | |
.ConfigureAppConfiguration((host, config) => | |
{ | |
config.AddJsonFile("ocelot.json"); | |
}) | |
.ConfigureWebHostDefaults(webBuilder => | |
{ | |
webBuilder.UseStartup<Startup>(); | |
}); |
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
await ResilientTransaction.New(_catalogContext).ExecuteAsync(async () => | |
{ | |
await _catalogContext.SaveChangesAsync(); | |
await _eventLogService.SaveEventAsync(evt, _catalogContext.Database.CurrentTransaction); | |
}); |
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 ResilientTransaction | |
{ | |
private DbContext _context; | |
private ResilientTransaction(DbContext context) => | |
_context = context ?? throw new ArgumentNullException(nameof(context)); | |
public static ResilientTransaction New (DbContext context) => | |
new ResilientTransaction(context); | |
public async Task ExecuteAsync(Func<Task> action) |
NewerOlder