├── .gitattributes
├── .gitignore
├── .vscode
├── cSpell.json
├── launch.json
└── tasks.json
├── GitVersion.yml
├── LICENSE.txt
├── README.md
├── build.ps1
├── build.sh
├── build
├── dotnet-install.ps1
├── dotnet-install.sh
└── tools.csproj
├── global.json
└── src
├── All.sln
├── Projac.Recipes
├── DataDefinition
│ ├── CreateSchema.cs
│ ├── DeleteData.cs
│ ├── DropSchema.cs
│ ├── SetCheckpoint.cs
│ └── Usage.cs
├── ElasticsearchIntegration
│ └── Usage.cs
├── Enveloping
│ └── Usage.cs
├── EventStoreIntegration
│ └── Usage.cs
├── MemoryCacheIntegration
│ ├── ProjectionUsage.cs
│ └── TestingUsage.cs
├── Projac.Recipes.csproj
├── RavenDBIntegration
│ ├── ProjectionUsage.cs
│ └── TestingUsage.cs
├── RedisIntegration
│ └── Usage.cs
├── SQLiteIntegration
│ └── Usage.cs
├── Shared
│ ├── PortfolioAdded.cs
│ ├── PortfolioRemoved.cs
│ └── PortfolioRenamed.cs
├── SqlStreamStoreIntegration
│ └── Usage.cs
├── Syntax
│ └── Usage.cs
├── WindowsAzureStorageIntegration
│ ├── PortfolioModel.cs
│ ├── RebuildProjection.cs
│ └── Usage.cs
└── app.config
├── Projac.SQLite.Tests
├── Projac.SQLite.Tests.csproj
├── SQLiteParameterAssertions.cs
├── SQLiteParameterEqualityComparer.cs
├── SQLiteParameterValueStub.cs
├── SQLiteSyntaxTestCases.cs
├── SQLiteSyntaxTests.Compose.cs
├── SQLiteSyntaxTests.DataTypes.cs
├── SQLiteSyntaxTests.NonQueryStatement.cs
├── SQLiteSyntaxTests.QueryStatement.cs
└── SQLiteSyntaxTests.cs
├── Projac.SQLite
├── Projac.SQLite.csproj
├── SQLiteDbParameterValue.cs
├── SQLiteSyntax.Compose.cs
├── SQLiteSyntax.NonQueryStatement.cs
├── SQLiteSyntax.QueryStatement.cs
├── SQLiteSyntax.cs
└── SqLiteSyntax.DataTypes.cs
├── Projac.Sql.Tests
├── AnonymousSqlProjectionBuilderTests.cs
├── AnonymousSqlProjectionTests.cs
├── AsyncSqlProjectorTests.cs
├── ConcurrentResolveTests.cs
├── Executors
│ ├── ConnectedSqlCommandExecutorTests.cs
│ ├── ConnectedTransactionalSqlCommandExecutorTests.cs
│ ├── SqlCommandExecutorTests.cs
│ ├── TestDbConnection.cs
│ ├── TestDbTransaction.cs
│ └── TransactionalSqlCommandExecutorTests.cs
├── Framework
│ └── SqlNonQueryCommandStub.cs
├── HandlerResolutionCases.cs
├── Projac.Sql.Tests.csproj
├── ProjectorProjectCases.cs
├── ResolveTests.cs
├── SqlNonQueryCommandComposerTests.cs
├── SqlNonQueryCommandTests.cs
├── SqlProjectionHandlerEnumeratorTests.cs
├── SqlProjectionHandlerTests.cs
├── SqlProjectionTests.cs
├── SqlProjectorTests.cs
└── SqlQueryStatementTests.cs
├── Projac.Sql
├── AnonymousSqlProjection.cs
├── AnonymousSqlProjectionBuilder.cs
├── AsyncSqlProjector.cs
├── ConcurrentResolve.cs
├── Executors
│ ├── ConnectedSqlCommandExecutor.cs
│ ├── ConnectedTransactionalSqlCommandExecutor.cs
│ ├── IAsyncSqlNonQueryCommandExecutor.cs
│ ├── IAsyncSqlQueryCommandExecutor.cs
│ ├── ISqlNonQueryCommandExecutor.cs
│ ├── ISqlQueryCommandExecutor.cs
│ ├── SqlCommandExecutor.cs
│ └── TransactionalSqlCommandExecutor.cs
├── IDbParameterValue.cs
├── Projac.Sql.csproj
├── Resolve.cs
├── SqlNonQueryCommand.cs
├── SqlNonQueryCommandComposer.cs
├── SqlProjection.cs
├── SqlProjectionHandler.cs
├── SqlProjectionHandlerEnumerator.cs
├── SqlProjectionHandlerResolver.cs
├── SqlProjector.cs
└── SqlQueryCommand.cs
├── Projac.SqlClient.Tests
├── Legacy
│ ├── TSqlTests.Compose.cs
│ ├── TSqlTests.DataTypes.cs
│ ├── TSqlTests.NonQueryProcedure.cs
│ ├── TSqlTests.NonQueryStatement.cs
│ ├── TSqlTests.ParameterCountLimitExceeded.cs
│ ├── TSqlTests.QueryProcedure.cs
│ └── TSqlTests.QueryStatement.cs
├── ParameterCountLimitedExceeded.cs
├── Projac.SqlClient.Tests.csproj
├── SqlClientSyntaxTestCases.cs
├── SqlClientSyntaxTests.Compose.cs
├── SqlClientSyntaxTests.DataTypes.cs
├── SqlClientSyntaxTests.NonQueryProcedure.cs
├── SqlClientSyntaxTests.NonQueryStatement.cs
├── SqlClientSyntaxTests.ParameterCountLimitExceeded.cs
├── SqlClientSyntaxTests.QueryProcedure.cs
├── SqlClientSyntaxTests.QueryStatement.cs
├── SqlClientSyntaxTests.cs
├── SqlParameterAssertions.cs
├── SqlParameterEqualityComparer.cs
├── SqlParameterValueStub.cs
├── TSqlBigIntNullValueTests.cs
├── TSqlBigIntValueTests.cs
├── TSqlBinaryNullValueTests.cs
├── TSqlBinarySizeTest.cs
├── TSqlBinaryValueTests.cs
├── TSqlBitNullValueTests.cs
├── TSqlBitValueTests.cs
├── TSqlCharNullValueTests.cs
├── TSqlCharSizeTest.cs
├── TSqlCharValueTests.cs
├── TSqlDateNullValueTests.cs
├── TSqlDateTime2NullValueTests.cs
├── TSqlDateTime2PrecisionTest.cs
├── TSqlDateTime2ValueTests.cs
├── TSqlDateTimeNullValueTests.cs
├── TSqlDateTimeOffsetNullValueTests.cs
├── TSqlDateTimeOffsetValueTests.cs
├── TSqlDateTimeValueTests.cs
├── TSqlDateValueTests.cs
├── TSqlDecimalNullValueTests.cs
├── TSqlDecimalPrecisionTest.cs
├── TSqlDecimalScaleTest.cs
├── TSqlDecimalValueTests.cs
├── TSqlIntNullValueTests.cs
├── TSqlIntValueTests.cs
├── TSqlMoneyNullValueTests.cs
├── TSqlMoneyValueTests.cs
├── TSqlNCharNullValueTests.cs
├── TSqlNCharSizeTest.cs
├── TSqlNCharValueTests.cs
├── TSqlNVarCharNullValueTests.cs
├── TSqlNVarCharSizeTest.cs
├── TSqlNVarCharValueTests.cs
├── TSqlUniqueIdentifierNullValueTests.cs
├── TSqlUniqueIdentifierValueTests.cs
├── TSqlVarBinaryNullValueTests.cs
├── TSqlVarBinarySizeTest.cs
├── TSqlVarBinaryValueTests.cs
├── TSqlVarCharNullValueTests.cs
├── TSqlVarCharSizeTest.cs
└── TSqlVarCharValueTests.cs
├── Projac.SqlClient
├── Legacy
│ ├── TSql.Compose.cs
│ ├── TSql.DataTypes.cs
│ ├── TSql.NonQueryProcedure.cs
│ ├── TSql.NonQueryStatement.cs
│ ├── TSql.QueryProcedure.cs
│ ├── TSql.QueryStatement.cs
│ └── TSql.cs
├── Limits.cs
├── Projac.SqlClient.csproj
├── SqlClientSyntax.Compose.cs
├── SqlClientSyntax.DataTypes.cs
├── SqlClientSyntax.NonQueryProcedure.cs
├── SqlClientSyntax.NonQueryStatement.cs
├── SqlClientSyntax.QueryProcedure.cs
├── SqlClientSyntax.QueryStatement.cs
├── SqlClientSyntax.cs
├── TSqlBigIntNullValue.cs
├── TSqlBigIntValue.cs
├── TSqlBinaryNullValue.cs
├── TSqlBinarySize.cs
├── TSqlBinaryValue.cs
├── TSqlBitNullValue.cs
├── TSqlBitValue.cs
├── TSqlCharNullValue.cs
├── TSqlCharSize.cs
├── TSqlCharValue.cs
├── TSqlDateNullValue.cs
├── TSqlDateTime2NullValue.cs
├── TSqlDateTime2Precision.cs
├── TSqlDateTime2Value.cs
├── TSqlDateTimeNullValue.cs
├── TSqlDateTimeOffsetNullValue.cs
├── TSqlDateTimeOffsetValue.cs
├── TSqlDateTimeValue.cs
├── TSqlDateValue.cs
├── TSqlDecimalNullValue.cs
├── TSqlDecimalPrecision.cs
├── TSqlDecimalScale.cs
├── TSqlDecimalValue.cs
├── TSqlIntNullValue.cs
├── TSqlIntValue.cs
├── TSqlMoneyNullValue.cs
├── TSqlMoneyValue.cs
├── TSqlNCharNullValue.cs
├── TSqlNCharSize.cs
├── TSqlNCharValue.cs
├── TSqlNVarCharNullValue.cs
├── TSqlNVarCharSize.cs
├── TSqlNVarCharValue.cs
├── TSqlUniqueIdentifierNullValue.cs
├── TSqlUniqueIdentifierValue.cs
├── TSqlVarBinaryNullValue.cs
├── TSqlVarBinarySize.cs
├── TSqlVarBinaryValue.cs
├── TSqlVarCharNullValue.cs
├── TSqlVarCharSize.cs
└── TSqlVarCharValue.cs
├── Projac.Tests
├── AnonymousProjectionBuilderTests.cs
├── AnonymousProjectionTests.cs
├── CallRecordingConnection.cs
├── ConcurrentResolveTests.cs
├── HandlerResolutionCases.cs
├── Projac.Tests.csproj
├── ProjectionHandlerEnumeratorTests.cs
├── ProjectionHandlerTests.cs
├── ProjectionTests.cs
├── ProjectorProjectCases.cs
├── ProjectorTests.cs
├── ResolveTests.cs
├── Signal.cs
└── Testing
│ ├── ProjectionScenarioTests.cs
│ ├── ProjectionTestSpecificationTests.cs
│ └── VerificationResultTests.cs
├── Projac
├── AnonymousProjection.cs
├── AnonymousProjectionBuilder.cs
├── ConcurrentResolve.cs
├── Projac.csproj
├── Projection.cs
├── ProjectionHandler.cs
├── ProjectionHandlerEnumerator.cs
├── ProjectionHandlerResolver.cs
├── Projector.cs
├── Resolve.cs
├── TaskExtensions.cs
└── Testing
│ ├── ProjectionScenario.cs
│ ├── ProjectionTestSpecification.cs
│ ├── VerificationResult.cs
│ └── VerificationResultState.cs
└── Recipes
├── Enveloping
└── Usage.cs
├── Recipes.csproj
├── SqlStreamStoreIntegration
└── Usage.cs
└── packages.config
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | obj
3 | build/tools
--------------------------------------------------------------------------------
/.vscode/cSpell.json:
--------------------------------------------------------------------------------
1 | // cSpell Settings
2 | {
3 | // Version of the setting file. Always 0.1
4 | "version": "0.1",
5 | // language - current active spelling language
6 | "language": "en",
7 | // words - list of words to be always considered correct
8 | "words": [
9 | "Projac"
10 | ],
11 | // flagWords - list of words to be always considered incorrect
12 | // This is useful for offensive words and common spelling errors.
13 | // For example "hte" should be "the"
14 | "flagWords": [
15 | "hte"
16 | ]
17 | }
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceRoot}/src/Projac.Tests/bin/Debug/netcoreapp2.0/Projac.Tests.dll",
14 | "args": [],
15 | "cwd": "${workspaceRoot}/src/Projac.Tests",
16 | // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
17 | "console": "internalConsole",
18 | "stopAtEntry": false,
19 | "internalConsoleOptions": "openOnSessionStart"
20 | },
21 | {
22 | "name": ".NET Core Attach",
23 | "type": "coreclr",
24 | "request": "attach",
25 | "processId": "${command:pickProcess}"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.1.0",
3 | "command": "dotnet",
4 | "isShellCommand": true,
5 | "args": [],
6 | "tasks": [
7 | {
8 | "taskName": "build",
9 | "args": [
10 | "${workspaceRoot}/src/Projac.Tests/Projac.Tests.csproj"
11 | ],
12 | "isBuildCommand": true,
13 | "problemMatcher": "$msCompile"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/GitVersion.yml:
--------------------------------------------------------------------------------
1 | assembly-versioning-scheme: MajorMinorPatch
2 | mode: ContinuousDelivery
3 | next-version: 0.1.0
4 | branches: {}
5 | ignore:
6 | sha: []
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 | ====================
3 |
4 | Copyright (c) 2013, Yves Reynhout
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8 |
9 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11 | Neither the name of the BitTacklr nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Projac
2 |
3 | Projac is a set of .NET libraries that allow you to author projections targeting various backing stores and is easy to integrate with existing event stores such as [EventStore](http://www.eventstore.org) and [SQLStreamStore](https://github.com/SQLStreamStore). [](https://gitter.im/yreynhout/Projac?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4 |
5 | - [Projac](https://github.com/BitTacklr/Projac/wiki/projac) allows you to author projections that target any store for which you can bring your own connection (e.g [Redis](http://redis.io), [RavenDB](http://ravendb.net/), [Elasticsearch](http://http://www.elasticsearch.org/), [Microsoft Windows Azure Table Storage](http://azure.microsoft.com/en-us/documentation/services/storage/)).
6 |
7 | - [Projac.Sql, Projac.SqlClient and Projac.SQLite](https://github.com/BitTacklr/Projac/wiki/projac.sql) allow you to author projections that target relational databases. Projac.Sql contains common abstractions across all database providers that use the ADO.NET model. Projac.SqlClient targets [Microsoft SQL Server](http://www.microsoft.com/en-us/server-cloud/products/sql-server-editions/overview.aspx). Projac.SQLite targets [SQLite](http://sqlite.org). We welcome contributions for other database providers that follow a similar recipe.
8 |
9 | It's available on both NuGet & MyGet:
10 |
11 | - Projac: [NuGet](https://www.nuget.org/packages/Projac/) - [MyGet](https://www.myget.org/feed/projac/package/nuget/Projac)
12 | - Projac.Sql: [NuGet](https://www.nuget.org/packages/Projac,Sql/) - [MyGet](https://www.myget.org/feed/projac/package/nuget/Projac.Sql)
13 | - Projac.SqlClient: [NuGet](https://www.nuget.org/packages/Projac.SqlClient/) - [MyGet](https://www.myget.org/feed/projac/package/nuget/Projac.SqlClient)
14 | - [WIP] Projac.SQLite: [NuGet](https://www.nuget.org/packages/Projac,SQLite/) - [MyGet](https://www.myget.org/feed/projac/package/nuget/Projac.SQLite)
15 |
16 | The custom MyGet feed can be found [here](https://www.myget.org/F/projac/api/v3/index.json).
17 |
18 | ---
19 |
20 | **Important Changes**
21 |
22 | If you're using a version prior to 0.1.0, not only has your cheese been moved, it probably has been broken in unexpected places. Please check out the [changes made in 0.1.0](https://github.com/BitTacklr/Projac/wiki/Changes0.1.0) as well as the [how do I upgrade to 0.1.0 guide](https://github.com/BitTacklr/Projac/wiki/UpgradeTo0.1.0). If you want to keep your cheese as is, you can always fork this code base and use the `legacy` branch.
23 |
24 | ---
25 |
26 | # Contributions
27 |
28 | * Date, DateTime, DateTime2, Money data types in TSql by [@xt0rted](https://github.com/xt0rted)
29 | * The ``positional syntax`` suggestion by [@tojans](https://github.com/tojans).
30 | * Decimal data type in SqlClientSyntax by [@ritasker](https://github.com/ritasker)
31 |
--------------------------------------------------------------------------------
/build/tools.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0;net46;net452
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "2.0.2"
4 | }
5 | }
--------------------------------------------------------------------------------
/src/Projac.Recipes/DataDefinition/CreateSchema.cs:
--------------------------------------------------------------------------------
1 | namespace Recipes.DataDefinition
2 | {
3 | ///
4 | /// Instructs a projection to create its schema objects.
5 | ///
6 | public class CreateSchema
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/src/Projac.Recipes/DataDefinition/DeleteData.cs:
--------------------------------------------------------------------------------
1 | namespace Recipes.DataDefinition
2 | {
3 | ///
4 | /// Instructs a projection to delete its data.
5 | ///
6 | public class DeleteData
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/src/Projac.Recipes/DataDefinition/DropSchema.cs:
--------------------------------------------------------------------------------
1 | namespace Recipes.DataDefinition
2 | {
3 | ///
4 | /// Instructs a projection to drop its schema objects.
5 | ///
6 | public class DropSchema
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/src/Projac.Recipes/DataDefinition/SetCheckpoint.cs:
--------------------------------------------------------------------------------
1 | namespace Recipes.DataDefinition
2 | {
3 | ///
4 | /// Instructs a projection to record its checkpoint.
5 | ///
6 | public class SetCheckpoint
7 | {
8 | ///
9 | /// The checkpoint the projection is at.
10 | ///
11 | public readonly long Checkpoint;
12 |
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The checkpoint the projection is at.
17 | public SetCheckpoint(long checkpoint)
18 | {
19 | Checkpoint = checkpoint;
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/Projac.Recipes/DataDefinition/Usage.cs:
--------------------------------------------------------------------------------
1 | using System.Security.Cryptography;
2 | using System.Text;
3 | using Projac.Sql;
4 | using Projac.SqlClient;
5 |
6 | namespace Recipes.DataDefinition
7 | {
8 | public static class Usage
9 | {
10 | private static readonly byte[] Id = "Sample".HashId();
11 |
12 | public class SampleUsingProjection : SqlClientProjection
13 | {
14 | public SampleUsingProjection()
15 | {
16 | When(_ =>
17 | Sql.NonQueryStatement(
18 | "CREATE TABLE [Sample] ([Id] INT NOT NULL CONSTRAINT PK_Sample PRIMARY KEY, [Value] INT NOT NULL)"));
19 |
20 | When(_ =>
21 | Sql.NonQueryStatement(
22 | "DROP TABLE [Sample]"));
23 |
24 | When(_ =>
25 | Sql.NonQueryStatement(
26 | "DELETE FROM [Sample]"));
27 |
28 | When(_ =>
29 | Sql.NonQueryStatement(
30 | "UPDATE [CheckpointGate] SET Checkpoint = @Checkpoint WHERE [Id] = @Id",
31 | new
32 | {
33 | Checkpoint = Sql.BigInt(_.Checkpoint),
34 | Id = Sql.Binary(Id, 16)
35 | }));
36 | }
37 | }
38 |
39 | public class SqlClientProjection : SqlProjection
40 | {
41 | private static readonly SqlClientSyntax Syntax = new SqlClientSyntax();
42 |
43 | protected SqlClientSyntax Sql
44 | {
45 | get { return Syntax; }
46 | }
47 | }
48 |
49 | public static class SampleUsingBuilder
50 | {
51 | private static readonly SqlClientSyntax Sql = new SqlClientSyntax();
52 |
53 | public static readonly AnonymousSqlProjection Instance = new AnonymousSqlProjectionBuilder().
54 | When(_ =>
55 | Sql.NonQueryStatement(
56 | "CREATE TABLE [Sample] ([Id] INT NOT NULL CONSTRAINT PK_Sample PRIMARY KEY, [Value] INT NOT NULL)")).
57 | When(_ =>
58 | Sql.NonQueryStatement(
59 | "DROP TABLE [Sample]")).
60 | When(_ =>
61 | Sql.NonQueryStatement(
62 | "DELETE FROM [Sample]")).
63 | When(_ =>
64 | Sql.NonQueryStatement(
65 | "UPDATE [CheckpointGate] SET Checkpoint = @Checkpoint WHERE [Id] = @Id",
66 | new
67 | {
68 | Checkpoint = Sql.BigInt(_.Checkpoint),
69 | Id = Sql.Binary(Id, 16)
70 | })).
71 | Build();
72 | }
73 |
74 | private static byte[] HashId(this string value)
75 | {
76 | using (var hash = MD5.Create())
77 | return hash.ComputeHash(Encoding.UTF8.GetBytes(value));
78 | }
79 | }
80 | }
81 |
82 |
--------------------------------------------------------------------------------
/src/Projac.Recipes/ElasticsearchIntegration/Usage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Elasticsearch.Net;
4 | using Newtonsoft.Json;
5 | using NUnit.Framework;
6 | using Projac;
7 | using Recipes.Shared;
8 |
9 | namespace Recipes.ElasticsearchIntegration
10 | {
11 | [TestFixture, Ignore("Because 'Explicit' is not respected by R#")]
12 | public class Usage
13 | {
14 | [Test]
15 | public async Task Show()
16 | {
17 | //Spin up a docker image of elastic search and/or change the endpoint below
18 | var config = new ConnectionConfiguration(new Uri("http://192.168.99.100:32769/"));
19 | var client = new ElasticLowLevelClient(config);
20 | var portfolioId = Guid.NewGuid();
21 | await new Projector(Resolve.WhenEqualToHandlerMessageType(Projection.Handlers)).
22 | ProjectAsync(client, new object[]
23 | {
24 | new PortfolioAdded {Id = portfolioId, Name = "My portfolio"},
25 | new PortfolioRenamed {Id = portfolioId, Name = "Your portfolio"},
26 | new PortfolioRemoved {Id = portfolioId}
27 | });
28 | }
29 |
30 | public static AnonymousProjection Projection = new AnonymousProjectionBuilder().
31 | When((client, message) =>
32 | client.IndexAsync