Skip to content

Instantly share code, notes, and snippets.

@sugimomoto
Last active February 7, 2020 01:47
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/da3ed8231ee99fb34f8e9894fab61ee0 to your computer and use it in GitHub Desktop.
Save sugimomoto/da3ed8231ee99fb34f8e9894fab61ee0 to your computer and use it in GitHub Desktop.
CData.SqlKata.SQLServerSample
using System;
using SqlKata;
using SqlKata.Execution;
using SqlKata.Compilers;
using System.Data.SqlClient;
namespace CData.SqlKata.CDataSampleProject
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var connection = new SqlConnection("Data Source=localhost;Initial Catalog=AdventureWorks2014;Integrated Security=True");
var compiler = new SqlServerCompiler();
var db = new QueryFactory(connection, compiler);
var persons = db.Query("Person.Person").Limit(10).Get<Person>();
foreach (var item in persons)
Console.WriteLine($"BusinessEntityID: {item.BusinessEntityID}; FirstName: {item.FirstName}; LastName: {item.LastName};");
Console.ReadKey();
}
}
public class Person
{
public string BusinessEntityID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment