Skip to content

Instantly share code, notes, and snippets.

@ichiroku11
ichiroku11 / BlobSample.cs
Last active June 24, 2022 08:24
Azure Blobのサンプル
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
namespace ConsoleApp {
// Blobサンプル
@ichiroku11
ichiroku11 / BinaryReaderExtensions.cs
Last active January 25, 2022 05:22
.NETで名前付きパイプを試す
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NamedPipe.ConsoleApp {
// BinaryReaderの拡張メソッドを定義
public static class BinaryReaderExtensions {
@ichiroku11
ichiroku11 / Client.cs
Last active March 2, 2021 05:24
.NETでTCP(TcpClientとTcpListener)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace Tcp.ConsoleApp {
// クライアント
@ichiroku11
ichiroku11 / Monster.sql
Created November 2, 2017 03:17
EF Coreで楽観的同時実行制御
use Test;
begin tran;
-- テーブル作成
drop table if exists dbo.Monster;
create table dbo.Monster(
Id int,
Name nvarchar(20) not null,
Version rowversion not null,
using System;
namespace ConsoleApp {
class Program {
static void Main(string[] args) {
Console.WriteLine("Hello World!");
}
}
}
@ichiroku11
ichiroku11 / AccountController.cs
Last active February 14, 2019 04:36
ASP.NET Core MVC - クッキー認証(https://github.com/ichiroku11/Sample へ)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@ichiroku11
ichiroku11 / Program.cs
Last active January 25, 2019 00:01
Enumerable.PrependとEnumerable.Append(https://github.com/ichiroku11/Sample に移動)
using System;
using System.Linq;
namespace ConsoleApp {
class Program {
static void Main(string[] args) {
// シーケンス
var source = new[] { 2, 3, 4 };
// Prepend:シーケンスの先頭に値を追加する
@ichiroku11
ichiroku11 / Program.cs
Last active December 18, 2018 11:35
EF CoreのIncludeとThenInclude
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
@ichiroku11
ichiroku11 / HomeController.cs
Created December 4, 2018 04:01
ASP.NET Core MVCでSerilogを使う
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace WebApp.Controllers {
public class HomeController : Controller {
@ichiroku11
ichiroku11 / Program.cs
Last active October 23, 2018 03:00
AutoMapper - 継承したオブジェクトをマッピングする
using System;
using AutoMapper;
namespace ConsoleApp {
// コピー元の親クラス
public abstract class SampleSrcBase {
public int Id { get; set; }
public string Value1 { get; set; }
}