Skip to content

Instantly share code, notes, and snippets.

@ElvisLives
Created October 31, 2012 16:32
Show Gist options
  • Save ElvisLives/3988101 to your computer and use it in GitHub Desktop.
Save ElvisLives/3988101 to your computer and use it in GitHub Desktop.
Testing out dapper against sql azure
using System;
using System.Data.SqlClient;
using System.Linq;
using Dapper;
using Xunit;
namespace Dapper.Testing
{
public class DapperyQueryTest
{
[Fact]
public void Blah()
{
int clientToSearchFor = 5;
const string connectionString = "Nope";
using (var connection = new SqlConnection(connectionString))
{
connection.Open();
var positionCounts = connection.Query<PositionCounts>(
"Select * from lstdata.PositionCounts where clientId = @clientID",
new { clientId = clientToSearchFor }).ToList();
foreach (var positionCountse in positionCounts)
{
Console.Out.WriteLine(positionCountse);
}
}
}
private class PositionCounts
{
public int Id { get; set; }
public int ClientId { get; set; }
public int ProcessBatchId { get; set; }
public string Engine { get; set; }
public string Keyword { get; set; }
public int LocationCount { get; set; }
public int Top10Count { get; set; }
public int Top10Percent { get; set; }
public int Top5Count { get; set; }
public int Top5Percent { get; set; }
public int Top1Count { get; set; }
public int Top1Percent { get; set; }
public DateTime TimeStamp { get; set; }
public override string ToString()
{
return string.Format("Id: {0}, ClientId: {1}, ProcessBatchId: {2}, Engine: {3}, Keyword: {4}, LocationCount: {5}, Top10Count: {6}, Top10Percent: {7}, Top5Count: {8}, Top5Percent: {9}, Top1Count: {10}, Top1Percent: {11}, TimeStamp: {12}", Id, ClientId, ProcessBatchId, Engine, Keyword, LocationCount, Top10Count, Top10Percent, Top5Count, Top5Percent, Top1Count, Top1Percent, TimeStamp);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment