Skip to content

Commit 40ab73b

Browse files
committed
QuerySingle<T7>(commandText, commandType, parameters, splitOn)
1 parent 3ab5436 commit 40ab73b

4 files changed

Lines changed: 16 additions & 7 deletions

File tree

src/Dibix.Dapper/DapperDatabaseAccessor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ protected override IEnumerable<TReturn> QueryMany<TFirst, TSecond, TThird, TFour
8080
return base.Connection.Query(commandText, map, CollectParameters(parameters), this._transaction, commandType: commandType, splitOn: splitOn);
8181
}
8282

83+
protected override IEnumerable<TReturn> QueryMany<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(string commandText, CommandType commandType, ParametersVisitor parameters, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn> map, string splitOn)
84+
{
85+
DecoratedTypeMap.Adapt<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh>();
86+
return base.Connection.Query(commandText, map, CollectParameters(parameters), this._transaction, commandType: commandType, splitOn: splitOn);
87+
}
88+
8389
protected override IEnumerable<TReturn> QueryMany<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth, TReturn>(string commandText, CommandType commandType, ParametersVisitor parameters, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth, TReturn> map, string splitOn)
8490
{
8591
DecoratedTypeMap.Adapt<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth>();

src/Dibix/Access/DatabaseAccessor.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ protected DatabaseAccessor(DbConnection connection, Action onDispose)
115115
.Single();
116116
});
117117

118+
public TReturn QuerySingle<TReturn, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh>(string commandText, CommandType commandType, ParametersVisitor parameters, string splitOn) where TReturn : new() => Execute(commandText, commandType, parameters, () =>
119+
{
120+
MultiMapper multiMapper = new MultiMapper();
121+
return this.QueryMany<TReturn, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(commandText, commandType, parameters, (a, b, c, d, e, f, g) => multiMapper.MapRow<TReturn>(useProjection: false, a, b, c, d, e, f, g), splitOn)
122+
.PostProcess(multiMapper)
123+
.Single();
124+
});
125+
118126
T IDatabaseAccessor.QuerySingleOrDefault<T>(string commandText, CommandType commandType, ParametersVisitor parameters) => Execute(commandText, commandType, parameters, () => this.QuerySingleOrDefault<T>(commandText, commandType, parameters).PostProcess());
119127

120128
IMultipleResultReader IDatabaseAccessor.QueryMultiple(string commandText, CommandType commandType, ParametersVisitor parameters) => Execute(commandText, commandType, parameters, () => this.QueryMultiple(commandText, commandType, parameters));
@@ -140,6 +148,7 @@ protected DatabaseAccessor(DbConnection connection, Action onDispose)
140148
protected abstract IEnumerable<TReturn> QueryMany<TFirst, TSecond, TThird, TFourth, TFifth, TReturn>(string commandText, CommandType commandType, ParametersVisitor parameters, Func<TFirst, TSecond, TThird, TFourth, TFifth, TReturn> map, string splitOn);
141149

142150
protected abstract IEnumerable<TReturn> QueryMany<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn>(string commandText, CommandType commandType, ParametersVisitor parameters, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn> map, string splitOn);
151+
protected abstract IEnumerable<TReturn> QueryMany<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(string commandText, CommandType commandType, ParametersVisitor parameters, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn> map, string splitOn);
143152

144153
protected abstract IEnumerable<TReturn> QueryMany<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth, TReturn>(string commandText, CommandType commandType, ParametersVisitor parameters, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth, TReturn> map, string splitOn);
145154

src/Dibix/Access/DatabaseAccessorExtensions.QuerySingle.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,5 @@ public static TReturn QuerySingle<TReturn, TSecond, TThird, TFourth>(this IDatab
9393
}, splitOn);
9494
return cache.Single();
9595
}
96-
97-
// OrderManagement (LoadOrder)
98-
public static TReturn QuerySingle<TReturn, TSecond, TThird, TFourth, TFifth>(this IDatabaseAccessor accessor, string commandText, ParametersVisitor parameters, string splitOn) where TReturn : new()
99-
{
100-
Guard.IsNotNull(accessor, nameof(accessor));
101-
return accessor.QuerySingle<TReturn, TSecond, TThird, TFourth, TFifth>(commandText, CommandType.Text, parameters, splitOn);
102-
}
10396
}
10497
}

src/Dibix/Access/IDatabaseAccessor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public interface IDatabaseAccessor : IDisposable
2929
TReturn QuerySingle<TReturn, TSecond, TThird>(string commandText, CommandType commandType, ParametersVisitor parameters, string splitOn) where TReturn : new();
3030
TReturn QuerySingle<TReturn, TSecond, TThird, TFourth>(string commandText, CommandType commandType, ParametersVisitor parameters, string splitOn) where TReturn : new();
3131
TReturn QuerySingle<TReturn, TSecond, TThird, TFourth, TFifth>(string commandText, CommandType commandType, ParametersVisitor parameters, string splitOn) where TReturn : new();
32+
TReturn QuerySingle<TReturn, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh>(string commandText, CommandType commandType, ParametersVisitor parameters, string splitOn) where TReturn : new();
3233
T QuerySingleOrDefault<T>(string commandText, CommandType commandType, ParametersVisitor parameters);
3334
IMultipleResultReader QueryMultiple(string commandText, CommandType commandType, ParametersVisitor parameters);
3435
Task<IMultipleResultReader> QueryMultipleAsync(string commandText, CommandType commandType, ParametersVisitor parameters, CancellationToken cancellationToken);

0 commit comments

Comments
 (0)