-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a837b3e
commit 290f549
Showing
4 changed files
with
84 additions
and
6 deletions.
There are no files selected for viewing
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
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,41 @@ | ||
using Npgsql; | ||
using NpgsqlTypes; | ||
|
||
namespace Weasel.Postgresql; | ||
|
||
public interface IGroupedParameterBuilder | ||
{ | ||
NpgsqlParameter AppendParameter<T>(T? value) where T : notnull; | ||
NpgsqlParameter AppendParameter<T>(T? value, NpgsqlDbType dbType) where T : notnull; | ||
} | ||
|
||
public sealed class GroupedParameterBuilder: IGroupedParameterBuilder | ||
{ | ||
private readonly ICommandBuilder _commandBuilder; | ||
private readonly char? _seperator; | ||
private int _count = 0; | ||
|
||
public GroupedParameterBuilder(ICommandBuilder commandBuilder, char? seperator) | ||
{ | ||
_commandBuilder = commandBuilder; | ||
_seperator = seperator; | ||
} | ||
|
||
public NpgsqlParameter AppendParameter<T>(T? value) where T : notnull | ||
{ | ||
if(_count > 0 && _seperator.HasValue) | ||
_commandBuilder.Append(_seperator.Value); | ||
|
||
_count++; | ||
return _commandBuilder.AppendParameter(value); | ||
} | ||
|
||
public NpgsqlParameter AppendParameter<T>(T? value, NpgsqlDbType dbType) where T : notnull | ||
{ | ||
if(_count > 0 && _seperator.HasValue) | ||
_commandBuilder.Append(_seperator.Value); | ||
|
||
_count++; | ||
return _commandBuilder.AppendParameter(value, dbType); | ||
} | ||
} |
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