Skip to content

Instantly share code, notes, and snippets.

@sugimomoto
Created February 5, 2020 08:36
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/ad75fd95d9dbfcbdf440f11312ff3dfe to your computer and use it in GitHub Desktop.
Save sugimomoto/ad75fd95d9dbfcbdf440f11312ff3dfe to your computer and use it in GitHub Desktop.
SqlKata by CData Sansan ADO.NET Provider
using System;
using SqlKata.Compilers;
using SqlKata.Execution;
using System.Data.CData.Sansan;
namespace CData.SqlKata.SampleProject
{
class Program
{
static void Main(string[] args)
{
// 通常 SqlConnection を渡すが、CData ADO.NET ProviderのConnectionを渡すように変更するだけ。
var connection = new SansanConnection("APIKey=XXXXXX;range=me;");
var compiler = new SqlServerCompiler();
var db = new QueryFactory(connection, compiler);
var response = db.Query("Bizcards").Select("BizcardId", "CompanyName").Get<Bizcards>();
foreach (var item in response)
{
Console.WriteLine($"BizcardId: {item.BizcardId}; CompanyName: {item.CompanyName}");
}
}
}
internal class Bizcards
{
public string BizcardId { get; set; }
public string CompanyName { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment