forked from MassTransit/Sample-Batch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MassTransit#5. Fixing dependencies on SqlLockStatementProvider
- Loading branch information
Showing
3 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/SampleBatch.Components/CustomSqlLockStatementFormatter.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using MassTransit.EntityFrameworkCoreIntegration; | ||
using System.Text; | ||
|
||
namespace SampleBatch.Components | ||
{ | ||
internal class CustomSqlLockStatementFormatter : ILockStatementFormatter | ||
{ | ||
public void Create(StringBuilder sb, string schema, string table) | ||
{ | ||
sb.AppendFormat("SELECT * FROM [{0}].{1} WITH (UPDLOCK, ROWLOCK, SERIALIZABLE) WHERE ", schema, table); | ||
} | ||
|
||
public void AppendColumn(StringBuilder sb, int index, string columnName) | ||
{ | ||
if (index == 0) | ||
sb.AppendFormat("{0} = @p0", columnName); | ||
else | ||
sb.AppendFormat(" AND {0} = @p{1}", columnName, index); | ||
} | ||
|
||
public void Complete(StringBuilder sb) | ||
{ | ||
} | ||
|
||
public void CreateOutboxStatement(StringBuilder sb, string schema, string table, string columnName) | ||
{ | ||
sb.AppendFormat(@"SELECT TOP 1 * FROM [{0}].{1} WITH (UPDLOCK, ROWLOCK, READPAST) ORDER BY {2}", schema, table, columnName); | ||
} | ||
} | ||
} |
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
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