Advertisement
Guest User

Untitled

a guest
Nov 19th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. using Paramol.SqlClient;
  2. using Projac;
  3.  
  4. namespace Sample
  5. {
  6. public static class PortfolioProjectionUsingBuilder
  7. {
  8. public static readonly AnonymousSqlProjection Instance = new AnonymousSqlProjectionBuilder().
  9. When<PortfolioAdded>(@event =>
  10. TSql.NonQueryStatement(
  11. "INSERT INTO [Portfolio] (Id, Name) VALUES (@P1, @P2)",
  12. new { P1 = TSql.Int(@event.Id), P2 = TSql.NVarChar(@event.Name, 40) }
  13. )).
  14. When<PortfolioRemoved>(@event =>
  15. TSql.NonQueryStatement(
  16. "DELETE FROM [Portfolio] WHERE Id = @P1",
  17. new { P1 = TSql.Int(@event.Id) }
  18. )).
  19. When<PortfolioRenamed>(@event =>
  20. TSql.NonQueryStatement(
  21. "UPDATE [Portfolio] SET Name = @P2 WHERE Id = @P1",
  22. new { P1 = TSql.Int(@event.Id), P2 = TSql.NVarChar(@event.Name, 40) }
  23. )).
  24. Build();
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement