Skip to content

Instantly share code, notes, and snippets.

View arichika's full-sized avatar
🐹
i love hamster, we love hamster!

arichika taniguchi arichika

🐹
i love hamster, we love hamster!
View GitHub Profile
@arichika
arichika / SimpleFilePost.ps1
Created December 10, 2019 11:16
POST multiple files with multipart/form-data with PowerShell v5 / PowerShell v5 で 複数ファイルを multipart/form-data で POST する
##################################################################
## POST multiple files with multipart/form-data with PowerShell v5
##################################################################
## POST Uri
$uri = "https://localhost/"
## Consts
$successFiles = './success'
$tempFile = './tempfile'
@arichika
arichika / Blog:OneWorldDbClient:201908261200:SampleDiLogicA.cs
Created August 26, 2019 03:20
Blog:OneWorldDbClient:201908261200:SampleDiLogicA.cs
// SampleDiLogicA.cs
public async Task<int> SampleMethodAsync()
{
int i;
using (var txScope = await _dbManager.BeginTranRequiredAsync())
{
const string identifier = @"X000A";
// Dapper
@arichika
arichika / Blog:OneWorldDbClient:201908261200:Startup.cs
Last active August 26, 2019 03:19
Blog:OneWorldDbClient:201908261200:Startup.cs
// Startup.cs
services.AddScoped(_ =>
new OneWorldDbClientManager<YourEfDbContext>(
Configuration.GetConnectionString("DefaultConnection"),
(connection, transaction) =>
{
var dbContext = new YourEfDbContext(
new DbContextOptionsBuilder<YourEfDbContext>()
.UseSqlServer((DbConnection)connection)
.Options);
@arichika
arichika / EnableSystemVersionedTemporalTables.cs
Last active July 12, 2021 19:10
Entity Framework Core (EFCore) Enable System-Versioned Temporal Table with Code First
namespace EFCoreEnableSystemVersionedTemporalTables
{
public static class EnableSystemVersionedTemporalTables
{
private static readonly (string SysStartTimeString, string SysEndTimeString) TemporalTableAdditionalFileds = (SysStartTimeString: "SysStartTime", SysEndTimeString: "SysEndTime");
public static void AddAsSystemVersionedTemporalTable(this MigrationBuilder migrationBuilder, string tableName, string temporalScheme = null, string temporalTableSuffix = @"History")
{
var temporalTableName = $"{tableName}{temporalTableSuffix}";
var schemaName = temporalScheme ?? "dbo";
using System;
using System.Diagnostics;
using Microsoft.Azure.WebJobs.Host;
namespace Samples.SampleBizLogic.Tests
{
public class UnitTestTraceWriter : TraceWriter
{
private readonly Action<TraceEvent> _traceAction;
@arichika
arichika / HowToCdOptionsCore 20180201-02.cs
Created February 1, 2018 14:54
HowToCdOptionsCore 20180201-02
public static class SampleFunction2WithOptions
{
[FunctionName("SampleFunction2WithOptions")]
public static IActionResult Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequest req,
TraceWriter log,
[CbOptions(sectionKey: "SampleBizLogic:MyBizOptions", reloadOnChange: true)]MyBizOptions options )
{
//...
@arichika
arichika / HowToCdOptionsCore 20180201-01.cs
Last active February 1, 2018 14:53
HowToCdOptionsCore 20180201-01
public static class SampleFunction2WithOptions
{
[FunctionName("SampleFunction2WithOptions")]
public static IActionResult Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequest req,
TraceWriter log )
{
//...