SqlKata by CData Kintone ADO.NET Provider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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