Advertisement
Guest User

Untitled

a guest
May 29th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. using System;
  2. using Insight.Database;
  3. using Npgsql;
  4.  
  5. namespace Insight
  6. {
  7. public interface IRepository
  8. {
  9. [Sql("SELECT a + b FROM (SELECT :a AS a, :b AS b) AS t")]
  10. int Sum(IBar bar);
  11. }
  12.  
  13. public interface IFoo
  14. {
  15. int A { get; set; }
  16. }
  17.  
  18. public interface IBar : IFoo
  19. {
  20. int B { get; set; }
  21. }
  22.  
  23. public class Bar : IBar
  24. {
  25. public int A { get; set; }
  26. public int B { get; set; }
  27. }
  28.  
  29. class Program
  30. {
  31. static void Main()
  32. {
  33. const string connectionString = "MY_CONNECTION_STRING";
  34. var connection = new NpgsqlConnection(connectionString).As<IRepository>();
  35. Console.WriteLine(connection.Sum(new Bar { A = 42, B = 13 }));
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement