Skip to content

Commit 03e7f6d

Browse files
Improved XML docs.
1 parent 2f929dc commit 03e7f6d

5 files changed

Lines changed: 236 additions & 290 deletions

File tree

Core/Core/QueryResult.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ public static class QueryResultExtensions
151151
/// <returns>An enumerable that dequeues the results and returns a column mapped dictionary for each entry</returns>
152152
public static IEnumerable<Dictionary<string, object?>> DequeueAsMappedDictionaries(this QueryResult<Queue<object?[]>> source)
153153
{
154-
if (source is null) throw new ArgumentNullException(nameof(source));
155-
156-
return DequeueAsMappedDictionariesCore(source);
154+
return source is null
155+
? throw new ArgumentNullException(nameof(source))
156+
: DequeueAsMappedDictionariesCore(source);
157157

158-
static IEnumerable<Dictionary<string, object?>> DequeueAsMappedDictionariesCore(QueryResult<Queue<object?[]>> source)
158+
static IEnumerable<Dictionary<string, object?>> DequeueAsMappedDictionariesCore(QueryResult<Queue<object?[]>> source)
159159
{
160160
Contract.EndContractBlock();
161161

@@ -240,11 +240,11 @@ public static ValueTask<IEnumerable<T>> DequeueAs<T>(this ValueTask<QueryResult<
240240
/// <returns>An enumerable that dequeues the results and returns a column mapped dictionary for each entry</returns>
241241
public static IEnumerable<Dictionary<string, object?>> AsMappedDictionaries(this QueryResult<IEnumerable<object?[]>> source)
242242
{
243-
if (source is null) throw new ArgumentNullException(nameof(source));
244-
245-
return AsMappedDictionariesCore(source);
243+
return source is null
244+
? throw new ArgumentNullException(nameof(source))
245+
: AsMappedDictionariesCore(source);
246246

247-
static IEnumerable<Dictionary<string, object?>> AsMappedDictionariesCore(QueryResult<IEnumerable<object?[]>> source)
247+
static IEnumerable<Dictionary<string, object?>> AsMappedDictionariesCore(QueryResult<IEnumerable<object?[]>> source)
248248
{
249249
Contract.EndContractBlock();
250250

Core/ExpressiveCommandBase.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace Open.Database.Extensions;
1919
/// <typeparam name="TReader">The type of reader created by the command.</typeparam>
2020
/// <typeparam name="TDbType">The DB type enum to use for parameters.</typeparam>
2121
/// <typeparam name="TThis">The type of this class in order to facilitate proper expressive notation.</typeparam>
22+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0045:Convert to conditional expression", Justification = "<Pending>")]
2223
public abstract partial class ExpressiveCommandBase<TConnection, TCommand, TReader, TDbType, TThis>
2324
: IExecuteCommand<TCommand>, IExecuteReader<TReader>
2425
where TConnection : class, IDbConnection
@@ -156,7 +157,7 @@ protected ExpressiveCommandBase(
156157
protected TCommand PrepareCommand(TConnection connection)
157158
{
158159
var cmd = connection.CreateCommand(Type, Command, Timeout);
159-
if (!(cmd is TCommand c))
160+
if (cmd is not TCommand c)
160161
throw new InvalidCastException($"Actual command type ({cmd.GetType()}) is not compatible with expected command type ({typeof(TCommand)}).");
161162
if (Transaction != null)
162163
c.Transaction = Transaction;
@@ -226,14 +227,16 @@ public TThis AddParam(string name, object value)
226227
return (TThis)this;
227228
}
228229

229-
/// <summary>
230-
/// Adds a parameter to the params list.
231-
/// </summary>
232-
/// <param name="name">The name of the parameter.</param>
233-
/// <param name="value">The value of the parameter.</param>
234-
/// <param name="type">The database type of the parameter.</param>
235-
/// <returns>This instance for use in method chaining.</returns>
236-
public TThis AddParam<T>(string name, T? value, TDbType type)
230+
231+
232+
/// <summary>
233+
/// Adds a parameter to the params list.
234+
/// </summary>
235+
/// <param name="name">The name of the parameter.</param>
236+
/// <param name="value">The value of the parameter.</param>
237+
/// <param name="type">The database type of the parameter.</param>
238+
/// <returns>This instance for use in method chaining.</returns>
239+
public TThis AddParam<T>(string name, T? value, TDbType type)
237240
where T : struct
238241
{
239242
if (name is null) throw new ArgumentNullException(nameof(name));

Core/Extensions/Command._.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ public static void ExecuteReader(this IDbCommand command, Action<IDataReader> ha
277277
/// <summary>
278278
/// Executes a reader on a command with a transform function.
279279
/// </summary>
280+
/// <remarks>The default <see cref="CommandBehavior"/> will open a connection, execute the reader and close the connection it if was not already open.</remarks>
280281
/// <typeparam name="T">The return type of the transform function.</typeparam>
281282
/// <param name="command">The IDbCommand to generate a reader from.</param>
282283
/// <param name="transform">The transform function for each IDataRecord.</param>

Core/Extensions/DataRecord.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,10 @@ public static object[] GetValuesFromOrdinals(this IDataRecord record, IList<int>
325325
public static IEnumerable<(string Name, int Ordinal)> MatchingOrdinals(this IDataRecord record, IEnumerable<string> columnNames, bool sort = false)
326326
{
327327
// Normalize the requested column names to be lowercase.
328-
columnNames = columnNames.Select(c =>
329-
{
330-
if (string.IsNullOrWhiteSpace(c))
331-
throw new ArgumentException("Column names cannot be null or whitespace only.");
332-
return c.ToUpperInvariant();
333-
});
328+
columnNames = columnNames.Select(c
329+
=> string.IsNullOrWhiteSpace(c)
330+
? throw new ArgumentException("Column names cannot be null or whitespace only.")
331+
: c.ToUpperInvariant());
334332

335333
var actual = record.OrdinalMapping();
336334
if (sort)
@@ -367,13 +365,19 @@ public static (string Name, int Ordinal)[] GetMatchingOrdinals(this IDataRecord
367365
/// <returns>The enumerable of data type names.</returns>
368366
public static IEnumerable<string> DataTypeNames(this IDataRecord record)
369367
{
370-
if (record is null) throw new ArgumentNullException(nameof(record));
371-
Contract.EndContractBlock();
372-
373-
var fieldCount = record.FieldCount;
374-
for (var i = 0; i < fieldCount; i++)
375-
yield return record.GetDataTypeName(i);
376-
}
368+
return record is null
369+
? throw new ArgumentNullException(nameof(record))
370+
: DataTypeNamesCore(record);
371+
372+
static IEnumerable<string> DataTypeNamesCore(IDataRecord record)
373+
{
374+
Contract.EndContractBlock();
375+
376+
var fieldCount = record.FieldCount;
377+
for (var i = 0; i < fieldCount; i++)
378+
yield return record.GetDataTypeName(i);
379+
}
380+
}
377381

378382
/// <summary>
379383
/// Returns all the data type names for the columns of current result set.

0 commit comments

Comments
 (0)