Last active
November 19, 2015 18:20
-
-
Save jeremiahredekop/f57fc89396019215dac7 to your computer and use it in GitHub Desktop.
sample sql denormalizer using paramol & projac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Paramol.SqlClient; | |
using Projac; | |
namespace Sample | |
{ | |
public static class PortfolioProjectionUsingBuilder | |
{ | |
public static readonly AnonymousSqlProjection Instance = new AnonymousSqlProjectionBuilder(). | |
When<PortfolioAdded>(@event => | |
TSql.NonQueryStatement( | |
"INSERT INTO [Portfolio] (Id, Name) VALUES (@P1, @P2)", | |
new { P1 = TSql.Int(@event.Id), P2 = TSql.NVarChar(@event.Name, 40) } | |
)). | |
When<PortfolioRemoved>(@event => | |
TSql.NonQueryStatement( | |
"DELETE FROM [Portfolio] WHERE Id = @P1", | |
new { P1 = TSql.Int(@event.Id) } | |
)). | |
When<PortfolioRenamed>(@event => | |
TSql.NonQueryStatement( | |
"UPDATE [Portfolio] SET Name = @P2 WHERE Id = @P1", | |
new { P1 = TSql.Int(@event.Id), P2 = TSql.NVarChar(@event.Name, 40) } | |
)). | |
Build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/yreynhout/Projac/blob/master/Sql.md