Skip to content

Instantly share code, notes, and snippets.

@Hinidu
Created April 20, 2015 15:35
Show Gist options
  • Save Hinidu/d0e60d4e1638906dde49 to your computer and use it in GitHub Desktop.
Save Hinidu/d0e60d4e1638906dde49 to your computer and use it in GitHub Desktop.
Insight.Database issue 197
using System;
using Insight.Database;
using Npgsql;
namespace Insight
{
public interface IRepository
{
[Sql("SELECT a + b FROM (SELECT :a AS a, :b AS b) AS t")]
int Sum(IBar bar);
}
public interface IFoo
{
int A { get; set; }
}
public interface IBar : IFoo
{
int B { get; set; }
}
public class Bar : IBar
{
public int A { get; set; }
public int B { get; set; }
}
class Program
{
static void Main()
{
const string connectionString = "MY_CONNECTION_STRING";
var connection = new NpgsqlConnection(connectionString).As<IRepository>();
Console.WriteLine(connection.Sum(new Bar { A = 42, B = 13 }));
}
}
}
using System;
using Insight.Database;
using Npgsql;
namespace Insight
{
public interface IRepository
{
[Sql("SELECT a + b + c FROM (SELECT :a AS a, :b AS b, :c AS c) AS t")]
int Sum(int c, IBar bar);
}
public interface IFoo
{
}
public interface IBar : IFoo
{
int A { get; set; }
int B { get; set; }
}
public class Bar : IBar
{
public int A { get; set; }
public int B { get; set; }
}
class Program
{
static void Main()
{
const string connectionString = "MY_CONNECTION_STRING";
var connection = new NpgsqlConnection(connectionString).As<IRepository>();
Console.WriteLine(connection.Sum(10, new Bar { A = 42, B = 13 }));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment