Skip to content

Instantly share code, notes, and snippets.

@sugimomoto
Last active February 7, 2020 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sugimomoto/9b266cbf0f180ac4560f4fbd5a95041a to your computer and use it in GitHub Desktop.
Save sugimomoto/9b266cbf0f180ac4560f4fbd5a95041a to your computer and use it in GitHub Desktop.
SqlKata by CData Kintone ADO.NET Provider
using System;
using SqlKata;
using SqlKata.Execution;
using SqlKata.Compilers;
using System.Data.SqlClient;
using System.Data.CData.Kintone;
namespace CData.SqlKata.CDataSampleProject
{
class Program
{
static void Main(string[] args)
{
// 通常 SqlConnection を渡すが、CData ADO.NET ProviderのConnectionを渡すように変更するだけ。
var connection = new KintoneConnection("URL=https://XXXX.cybozu.com/;User=XXXXX;Password=XXXXX;");
var compiler = new SqlServerCompiler();
var db = new QueryFactory(connection, compiler);
// 日本語のクラス名も利用できる!
var response = db.Query("案件情報").Select("RecordId", "案件名").Get<案件情報>();
foreach (var item in response)
{
Console.WriteLine($"RecordId: {item.RecordId}; 案件名: {item.案件名}");
}
// 日本語名でInsertも可能
var query = new Query("案件情報").AsInsert(
new
{
案件名 = "ugauga"
}
);
db.Execute(query);
Console.ReadKey();
}
}
internal class 案件情報
{
public string RecordId { get; set; }
public string 案件名 { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment