Skip to content

Instantly share code, notes, and snippets.

@sugimomoto

sugimomoto/SqlKata.cs

Last active Feb 7, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.