Skip to content

Commit 5815af9

Browse files
committed
Replace all dynamic references by the ExpandoObject type
1 parent d657495 commit 5815af9

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/Sql/ConnectionExtensions.Async.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static async Task<IDataReader> ExecuteReaderAsync(this IDbConnection conn
7777
/// <param name="options">The command options.</param>
7878
/// <param name="cancellationToken">The token to cancel the operation.</param>
7979
/// <returns>The sequence of objects whose properties correspond to the columns.</returns>
80-
public static async Task<IEnumerable<dynamic>> QueryAsync(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null, CancellationToken cancellationToken = default) =>
80+
public static async Task<IEnumerable<ExpandoObject>> QueryAsync(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null, CancellationToken cancellationToken = default) =>
8181
await QueryAsync<ExpandoObject>(connection, sql, parameters, options, cancellationToken);
8282

8383
/// <summary>
@@ -103,7 +103,7 @@ public static async Task<IEnumerable<dynamic>> QueryAsync(this IDbConnection con
103103
/// <param name="cancellationToken">The token to cancel the operation.</param>
104104
/// <returns>The first row.</returns>
105105
/// <exception cref="InvalidOperationException">The result set is empty.</exception>
106-
public static async Task<dynamic> QueryFirstAsync(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null, CancellationToken cancellationToken = default) =>
106+
public static async Task<ExpandoObject> QueryFirstAsync(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null, CancellationToken cancellationToken = default) =>
107107
await QueryFirstAsync<ExpandoObject>(connection, sql, parameters, options, cancellationToken);
108108

109109
/// <summary>
@@ -131,7 +131,7 @@ public static async Task<dynamic> QueryFirstAsync(this IDbConnection connection,
131131
/// <param name="options">The command options.</param>
132132
/// <param name="cancellationToken">The token to cancel the operation.</param>
133133
/// <returns>The first row, or <see langword="null"/> if not found.</returns>
134-
public static async Task<dynamic?> QueryFirstOrDefaultAsync(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null, CancellationToken cancellationToken = default) =>
134+
public static async Task<ExpandoObject?> QueryFirstOrDefaultAsync(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null, CancellationToken cancellationToken = default) =>
135135
await QueryFirstOrDefaultAsync<ExpandoObject>(connection, sql, parameters, options, cancellationToken);
136136

137137
/// <summary>
@@ -159,7 +159,7 @@ public static async Task<dynamic> QueryFirstAsync(this IDbConnection connection,
159159
/// <param name="cancellationToken">The token to cancel the operation.</param>
160160
/// <returns>The single row.</returns>
161161
/// <exception cref="InvalidOperationException">The result set is empty or contains more than one record.</exception>
162-
public static async Task<dynamic> QuerySingleAsync(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null, CancellationToken cancellationToken = default) =>
162+
public static async Task<ExpandoObject> QuerySingleAsync(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null, CancellationToken cancellationToken = default) =>
163163
await QuerySingleAsync<ExpandoObject>(connection, sql, parameters, options, cancellationToken);
164164

165165
/// <summary>
@@ -195,7 +195,7 @@ record = mapper.CreateInstance<T>(reader);
195195
/// <param name="options">The command options.</param>
196196
/// <param name="cancellationToken">The token to cancel the operation.</param>
197197
/// <returns>The single row, or <see langword="null"/> if not found.</returns>
198-
public static async Task<dynamic?> QuerySingleOrDefaultAsync(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null, CancellationToken cancellationToken = default) =>
198+
public static async Task<ExpandoObject?> QuerySingleOrDefaultAsync(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null, CancellationToken cancellationToken = default) =>
199199
await QuerySingleOrDefaultAsync<ExpandoObject>(connection, sql, parameters, options, cancellationToken);
200200

201201
/// <summary>

src/Sql/ConnectionExtensions.Sync.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static IDataReader ExecuteReader(this IDbConnection connection, string sq
7171
/// <param name="parameters">The parameters of the SQL query.</param>
7272
/// <param name="options">The command options.</param>
7373
/// <returns>The sequence of objects whose properties correspond to the columns.</returns>
74-
public static IEnumerable<dynamic> Query(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null) =>
74+
public static IEnumerable<ExpandoObject> Query(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null) =>
7575
Query<ExpandoObject>(connection, sql, parameters, options);
7676

7777
/// <summary>
@@ -95,7 +95,7 @@ public static IEnumerable<dynamic> Query(this IDbConnection connection, string s
9595
/// <param name="options">The command options.</param>
9696
/// <returns>The first row.</returns>
9797
/// <exception cref="InvalidOperationException">The result set is empty.</exception>
98-
public static dynamic QueryFirst(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null) =>
98+
public static ExpandoObject QueryFirst(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null) =>
9999
QueryFirst<ExpandoObject>(connection, sql, parameters, options);
100100

101101
/// <summary>
@@ -121,7 +121,7 @@ public static dynamic QueryFirst(this IDbConnection connection, string sql, Para
121121
/// <param name="parameters">The parameters of the SQL query.</param>
122122
/// <param name="options">The command options.</param>
123123
/// <returns>The first row, or <see langword="null"/> if not found.</returns>
124-
public static dynamic? QueryFirstOrDefault(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null) =>
124+
public static ExpandoObject? QueryFirstOrDefault(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null) =>
125125
QueryFirstOrDefault<ExpandoObject>(connection, sql, parameters, options);
126126

127127
/// <summary>
@@ -147,7 +147,7 @@ public static dynamic QueryFirst(this IDbConnection connection, string sql, Para
147147
/// <param name="options">The command options.</param>
148148
/// <returns>The single row.</returns>
149149
/// <exception cref="InvalidOperationException">The result set is empty or contains more than one record.</exception>
150-
public static dynamic QuerySingle(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null) =>
150+
public static ExpandoObject QuerySingle(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null) =>
151151
QuerySingle<ExpandoObject>(connection, sql, parameters, options);
152152

153153
/// <summary>
@@ -181,7 +181,7 @@ record = mapper.CreateInstance<T>(reader);
181181
/// <param name="parameters">The parameters of the SQL query.</param>
182182
/// <param name="options">The command options.</param>
183183
/// <returns>The single row, or <see langword="null"/> if not found.</returns>
184-
public static dynamic? QuerySingleOrDefault(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null) =>
184+
public static ExpandoObject? QuerySingleOrDefault(this IDbConnection connection, string sql, ParameterCollection? parameters = null, CommandOptions? options = null) =>
185185
QuerySingleOrDefault<ExpandoObject>(connection, sql, parameters, options);
186186

187187
/// <summary>

src/Sql/Mapper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public sealed class Mapper {
2121
/// </summary>
2222
/// <param name="record">A data record providing the properties to be set on the created object.</param>
2323
/// <returns>The newly created object.</returns>
24-
public dynamic CreateInstance(IDataRecord record) => CreateInstance<ExpandoObject>(record);
24+
public ExpandoObject CreateInstance(IDataRecord record) => CreateInstance<ExpandoObject>(record);
2525

2626
/// <summary>
2727
/// Creates a new object of a given type from the specified data record.
@@ -44,7 +44,7 @@ public sealed class Mapper {
4444
/// </summary>
4545
/// <param name="properties">A dictionary providing the properties to be set on the created object.</param>
4646
/// <returns>The newly created object.</returns>
47-
public dynamic CreateInstance(IDictionary<string, object?> properties) => CreateInstance<ExpandoObject>(properties);
47+
public ExpandoObject CreateInstance(IDictionary<string, object?> properties) => CreateInstance<ExpandoObject>(properties);
4848

4949
/// <summary>
5050
/// Creates a new object of a given type from the specified dictionary.
@@ -74,7 +74,7 @@ public sealed class Mapper {
7474
/// </summary>
7575
/// <param name="reader">A data reader providing the properties to be set on the created objects.</param>
7676
/// <returns>An enumerable of newly created objects.</returns>
77-
public IEnumerable<dynamic> CreateInstances(IDataReader reader) => CreateInstances<ExpandoObject>(reader);
77+
public IEnumerable<ExpandoObject> CreateInstances(IDataReader reader) => CreateInstances<ExpandoObject>(reader);
7878

7979
/// <summary>
8080
/// Creates new objects of a given type from the specified data reader.

0 commit comments

Comments
 (0)