// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
// <auto-generated/>
global using global::Microsoft.AspNetCore.Builder;
global using global::Microsoft.AspNetCore.Hosting;
global using global::Microsoft.AspNetCore.Http;
global using global::Microsoft.AspNetCore.Routing;
global using global::Microsoft.Extensions.Configuration;
global using global::Microsoft.Extensions.DependencyInjection;
global using global::Microsoft.Extensions.Hosting;
global using global::Microsoft.Extensions.Logging;
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Net.Http.Json;
global using global::System.Threading;
global using global::System.Threading.Tasks;
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run();
public class Program
{
・・・
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSystemd()
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Worker>();
});
以下のようなSystemd用のサービス定義ファイルを作成。
[Unit]
Description=Worker Test on Linux Systemd
[Service]
Type=notify
WorkingDirectory=<作業ディレクトリ>
ExecStart=/usr/bin/dotnet <DLLのPATH>
[Install]
WantedBy=multi-user.target
using System.ServiceModel;
using ServiceReference; // svcutilでnamespaceを指定した場合はそのnamespace
・・・
// サービスアクセス用インスタンスの作成
var cli = new <サービス名>Client();
// サービスのメソッドを呼び出す
var result = await cli.<メソッド名>Async(<パラメータ>);
例
using System.ServiceModel;
using ServiceReference; // svcutilでnamespaceを指定した場合はそのnamespace
・・・
// GetUserService SOAPクライアント
// ※認証なし
var cli = new GetUserServiceClient();
// ユーザー番号00001番のユーザーを取得
// ※Userクラス定義はWSDLから自動的に生成される
User ret = await cli.GetUserAsync("00001");
LINQで内部結合(LEFT INNER JOIN)を行うには、JOIN句を使って、以下のような感じで行えば良いのは良く例も出ているし、構文上も素直に納得できる。 (ちなみに、複数キーがある場合は、 new {t1.key1,t1.key2[,…]} equals new {t2.key1,t2.key2[,…]} の形で指定する)
// Collection1とCollection2の[KEY]が同じものを結合
// 同じキーを含まないCollection1は集合から外される。
var q = from t1 in Collection1
join t2 in Collection2 on t2.[KEY] equals t1.[KEY]
・・・
// Collection1とCollection2の[KEY]が同じものを結合
// ただし、Collection2と同じキーを持っていないCollection1も集合に含める
var q = from t1 in Collection1
from t2 in Collection2.Where(c=>c.[KEY] == t1.[KEY]).DefaultIfEmpty()
・・・
> mbr2gpt /validate /disk:1 /allowFullOS
MBR2GPT: Attempting to validate disk 1
MBR2GPT: Retrieving layout of disk
MBR2GPT: Validating layout, disk sector size is: 512 bytes
MBR2GPT: Validation completed successfully
>