Commit 9a97a044 authored by Nick Craver's avatar Nick Craver

XMLDoc fixes for latest methods and missing DataSet in .NET Core

parent 806e3431
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
} }
}, },
"buildOptions": { "buildOptions": {
"xmlDoc": true,
"warningsAsErrors": true, "warningsAsErrors": true,
"compile": { "compile": {
"include": [ "include": [
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
} }
}, },
"buildOptions": { "buildOptions": {
"xmlDoc": true,
"warningsAsErrors": true "warningsAsErrors": true
}, },
"frameworks": { "frameworks": {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
"dependencies": { "dependencies": {
}, },
"buildOptions": { "buildOptions": {
"xmlDoc": true,
"keyFile": "../Dapper.snk", "keyFile": "../Dapper.snk",
"warningsAsErrors": true, "warningsAsErrors": true,
"compile": { "compile": {
......
...@@ -777,7 +777,7 @@ public static async Task<GridReader> QueryMultipleAsync(this IDbConnection cnn, ...@@ -777,7 +777,7 @@ public static async Task<GridReader> QueryMultipleAsync(this IDbConnection cnn,
/// <returns>An <see cref="IDataReader"/> that can be used to iterate over the results of the SQL query.</returns> /// <returns>An <see cref="IDataReader"/> that can be used to iterate over the results of the SQL query.</returns>
/// <remarks> /// <remarks>
/// This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="DataTable"/> /// This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="DataTable"/>
/// or <see cref="DataSet"/>. /// or <see cref="T:DataSet"/>.
/// </remarks> /// </remarks>
/// <example> /// <example>
/// <code> /// <code>
...@@ -804,7 +804,7 @@ public static async Task<GridReader> QueryMultipleAsync(this IDbConnection cnn, ...@@ -804,7 +804,7 @@ public static async Task<GridReader> QueryMultipleAsync(this IDbConnection cnn,
/// <returns>An <see cref="IDataReader"/> that can be used to iterate over the results of the SQL query.</returns> /// <returns>An <see cref="IDataReader"/> that can be used to iterate over the results of the SQL query.</returns>
/// <remarks> /// <remarks>
/// This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="DataTable"/> /// This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="DataTable"/>
/// or <see cref="DataSet"/>. /// or <see cref="T:DataSet"/>.
/// </remarks> /// </remarks>
public static Task<IDataReader> ExecuteReaderAsync(this IDbConnection cnn, CommandDefinition command) public static Task<IDataReader> ExecuteReaderAsync(this IDbConnection cnn, CommandDefinition command)
{ {
......
...@@ -6,6 +6,9 @@ namespace Dapper ...@@ -6,6 +6,9 @@ namespace Dapper
{ {
partial class SqlMapper partial class SqlMapper
{ {
/// <summary>
/// Parses a data reader to a sequence of data of the supplied type. Used for deserializing a reader without a connection, etc.
/// </summary>
public static IEnumerable<T> Parse<T>(this IDataReader reader) public static IEnumerable<T> Parse<T>(this IDataReader reader)
{ {
if(reader.Read()) if(reader.Read())
...@@ -17,6 +20,10 @@ public static IEnumerable<T> Parse<T>(this IDataReader reader) ...@@ -17,6 +20,10 @@ public static IEnumerable<T> Parse<T>(this IDataReader reader)
} while (reader.Read()); } while (reader.Read());
} }
} }
/// <summary>
/// Parses a data reader to a sequence of data of the supplied type (as object). Used for deserializing a reader without a connection, etc.
/// </summary>
public static IEnumerable<object> Parse(this IDataReader reader, Type type) public static IEnumerable<object> Parse(this IDataReader reader, Type type)
{ {
if (reader.Read()) if (reader.Read())
...@@ -28,6 +35,10 @@ public static IEnumerable<object> Parse(this IDataReader reader, Type type) ...@@ -28,6 +35,10 @@ public static IEnumerable<object> Parse(this IDataReader reader, Type type)
} while (reader.Read()); } while (reader.Read());
} }
} }
/// <summary>
/// Parses a data reader to a sequence of dynamic. Used for deserializing a reader without a connection, etc.
/// </summary>
public static IEnumerable<dynamic> Parse(this IDataReader reader) public static IEnumerable<dynamic> Parse(this IDataReader reader)
{ {
if (reader.Read()) if (reader.Read())
...@@ -40,11 +51,74 @@ public static IEnumerable<dynamic> Parse(this IDataReader reader) ...@@ -40,11 +51,74 @@ public static IEnumerable<dynamic> Parse(this IDataReader reader)
} }
} }
/// <summary>
/// Gets the row parser for a specific row on a data reader. This allows for type switching every row based on, for example, a TypeId column.
/// You could return a collection of the base type but have each more specific.
/// </summary>
/// <param name="reader">The data reader to get the parser for the current row from</param>
/// <param name="type">The type to get the parser for</param>
/// <param name="startIndex">The start column index of the object (default 0)</param>
/// <param name="length">The length of columns to read (default -1 = all fields following startIndex)</param>
/// <param name="returnNullIfFirstMissing">Return null if we can't find the first column? (default false)</param>
/// <returns>A parser for this specific object from this row.</returns>
public static Func<IDataReader, object> GetRowParser(this IDataReader reader, Type type, public static Func<IDataReader, object> GetRowParser(this IDataReader reader, Type type,
int startIndex = 0, int length = -1, bool returnNullIfFirstMissing = false) int startIndex = 0, int length = -1, bool returnNullIfFirstMissing = false)
{ {
return GetDeserializer(type, reader, startIndex, length, returnNullIfFirstMissing); return GetDeserializer(type, reader, startIndex, length, returnNullIfFirstMissing);
} }
/// <summary>
/// Gets the row parser for a specific row on a data reader. This allows for type switching every row based on, for example, a TypeId column.
/// You could return a collection of the base type but have each more specific.
/// </summary>
/// <param name="reader">The data reader to get the parser for the current row from</param>
/// <param name="concreteType">The type to get the parser for</param>
/// <param name="startIndex">The start column index of the object (default 0)</param>
/// <param name="length">The length of columns to read (default -1 = all fields following startIndex)</param>
/// <param name="returnNullIfFirstMissing">Return null if we can't find the first column? (default false)</param>
/// <returns>A parser for this specific object from this row.</returns>
/// <example>
/// var result = new List&lt;BaseType&gt;();
/// using (var reader = connection.ExecuteReader(@"
/// select 'abc' as Name, 1 as Type, 3.0 as Value
/// union all
/// select 'def' as Name, 2 as Type, 4.0 as Value"))
/// {
/// if (reader.Read())
/// {
/// var toFoo = reader.GetRowParser&lt;BaseType&gt;(typeof(Foo));
/// var toBar = reader.GetRowParser&lt;BaseType&gt;(typeof(Bar));
/// var col = reader.GetOrdinal("Type");
/// do
/// {
/// switch (reader.GetInt32(col))
/// {
/// case 1:
/// result.Add(toFoo(reader));
/// break;
/// case 2:
/// result.Add(toBar(reader));
/// break;
/// }
/// } while (reader.Read());
/// }
/// }
///
/// abstract class BaseType
/// {
/// public abstract int Type { get; }
/// }
/// class Foo : BaseType
/// {
/// public string Name { get; set; }
/// public override int Type =&gt; 1;
/// }
/// class Bar : BaseType
/// {
/// public float Value { get; set; }
/// public override int Type =&gt; 2;
/// }
/// </example>
public static Func<IDataReader, T> GetRowParser<T>(this IDataReader reader, Type concreteType = null, public static Func<IDataReader, T> GetRowParser<T>(this IDataReader reader, Type concreteType = null,
int startIndex = 0, int length = -1, bool returnNullIfFirstMissing = false) int startIndex = 0, int length = -1, bool returnNullIfFirstMissing = false)
{ {
......
...@@ -354,6 +354,10 @@ public static DbType GetDbType(object value) ...@@ -354,6 +354,10 @@ public static DbType GetDbType(object value)
return LookupDbType(value.GetType(), "n/a", false, out handler); return LookupDbType(value.GetType(), "n/a", false, out handler);
} }
/// <summary>
/// OBSOLETE: For internal usage only. Lookup the DbType and handler for a given Type and member
/// </summary>
[Obsolete(ObsoleteInternalUsageOnly, false)] [Obsolete(ObsoleteInternalUsageOnly, false)]
#if !COREFX #if !COREFX
[Browsable(false)] [Browsable(false)]
...@@ -554,7 +558,7 @@ private static int ExecuteImpl(this IDbConnection cnn, ref CommandDefinition com ...@@ -554,7 +558,7 @@ private static int ExecuteImpl(this IDbConnection cnn, ref CommandDefinition com
/// <returns>An <see cref="IDataReader"/> that can be used to iterate over the results of the SQL query.</returns> /// <returns>An <see cref="IDataReader"/> that can be used to iterate over the results of the SQL query.</returns>
/// <remarks> /// <remarks>
/// This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="DataTable"/> /// This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="DataTable"/>
/// or <see cref="DataSet"/>. /// or <see cref="T:DataSet"/>.
/// </remarks> /// </remarks>
/// <example> /// <example>
/// <code> /// <code>
...@@ -583,7 +587,7 @@ private static int ExecuteImpl(this IDbConnection cnn, ref CommandDefinition com ...@@ -583,7 +587,7 @@ private static int ExecuteImpl(this IDbConnection cnn, ref CommandDefinition com
/// <returns>An <see cref="IDataReader"/> that can be used to iterate over the results of the SQL query.</returns> /// <returns>An <see cref="IDataReader"/> that can be used to iterate over the results of the SQL query.</returns>
/// <remarks> /// <remarks>
/// This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="DataTable"/> /// This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="DataTable"/>
/// or <see cref="DataSet"/>. /// or <see cref="T:DataSet"/>.
/// </remarks> /// </remarks>
public static IDataReader ExecuteReader(this IDbConnection cnn, CommandDefinition command) public static IDataReader ExecuteReader(this IDbConnection cnn, CommandDefinition command)
{ {
...@@ -597,7 +601,7 @@ public static IDataReader ExecuteReader(this IDbConnection cnn, CommandDefinitio ...@@ -597,7 +601,7 @@ public static IDataReader ExecuteReader(this IDbConnection cnn, CommandDefinitio
/// <returns>An <see cref="IDataReader"/> that can be used to iterate over the results of the SQL query.</returns> /// <returns>An <see cref="IDataReader"/> that can be used to iterate over the results of the SQL query.</returns>
/// <remarks> /// <remarks>
/// This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="DataTable"/> /// This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="DataTable"/>
/// or <see cref="DataSet"/>. /// or <see cref="T:DataSet"/>.
/// </remarks> /// </remarks>
public static IDataReader ExecuteReader(this IDbConnection cnn, CommandDefinition command, CommandBehavior commandBehavior) public static IDataReader ExecuteReader(this IDbConnection cnn, CommandDefinition command, CommandBehavior commandBehavior)
{ {
...@@ -804,7 +808,7 @@ public static IEnumerable<T> Query<T>(this IDbConnection cnn, CommandDefinition ...@@ -804,7 +808,7 @@ public static IEnumerable<T> Query<T>(this IDbConnection cnn, CommandDefinition
/// Executes a query, returning the data typed as per T /// Executes a query, returning the data typed as per T
/// </summary> /// </summary>
/// <remarks>the dynamic param may seem a bit odd, but this works around a major usability issue in vs, if it is Object vs completion gets annoying. Eg type new [space] get new object</remarks> /// <remarks>the dynamic param may seem a bit odd, but this works around a major usability issue in vs, if it is Object vs completion gets annoying. Eg type new [space] get new object</remarks>
/// <returns>A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is /// <returns>A single instance or null of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is
/// created per row, and a direct column-name===member-name mapping is assumed (case insensitive). /// created per row, and a direct column-name===member-name mapping is assumed (case insensitive).
/// </returns> /// </returns>
public static T QueryFirst<T>(this IDbConnection cnn, CommandDefinition command) public static T QueryFirst<T>(this IDbConnection cnn, CommandDefinition command)
...@@ -815,7 +819,7 @@ public static T QueryFirst<T>(this IDbConnection cnn, CommandDefinition command) ...@@ -815,7 +819,7 @@ public static T QueryFirst<T>(this IDbConnection cnn, CommandDefinition command)
/// Executes a query, returning the data typed as per T /// Executes a query, returning the data typed as per T
/// </summary> /// </summary>
/// <remarks>the dynamic param may seem a bit odd, but this works around a major usability issue in vs, if it is Object vs completion gets annoying. Eg type new [space] get new object</remarks> /// <remarks>the dynamic param may seem a bit odd, but this works around a major usability issue in vs, if it is Object vs completion gets annoying. Eg type new [space] get new object</remarks>
/// <returns>A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is /// <returns>A single or null instance of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is
/// created per row, and a direct column-name===member-name mapping is assumed (case insensitive). /// created per row, and a direct column-name===member-name mapping is assumed (case insensitive).
/// </returns> /// </returns>
public static T QueryFirstOrDefault<T>(this IDbConnection cnn, CommandDefinition command) public static T QueryFirstOrDefault<T>(this IDbConnection cnn, CommandDefinition command)
...@@ -826,7 +830,7 @@ public static T QueryFirstOrDefault<T>(this IDbConnection cnn, CommandDefinition ...@@ -826,7 +830,7 @@ public static T QueryFirstOrDefault<T>(this IDbConnection cnn, CommandDefinition
/// Executes a query, returning the data typed as per T /// Executes a query, returning the data typed as per T
/// </summary> /// </summary>
/// <remarks>the dynamic param may seem a bit odd, but this works around a major usability issue in vs, if it is Object vs completion gets annoying. Eg type new [space] get new object</remarks> /// <remarks>the dynamic param may seem a bit odd, but this works around a major usability issue in vs, if it is Object vs completion gets annoying. Eg type new [space] get new object</remarks>
/// <returns>A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is /// <returns>A single instance of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is
/// created per row, and a direct column-name===member-name mapping is assumed (case insensitive). /// created per row, and a direct column-name===member-name mapping is assumed (case insensitive).
/// </returns> /// </returns>
public static T QuerySingle<T>(this IDbConnection cnn, CommandDefinition command) public static T QuerySingle<T>(this IDbConnection cnn, CommandDefinition command)
...@@ -837,7 +841,7 @@ public static T QuerySingle<T>(this IDbConnection cnn, CommandDefinition command ...@@ -837,7 +841,7 @@ public static T QuerySingle<T>(this IDbConnection cnn, CommandDefinition command
/// Executes a query, returning the data typed as per T /// Executes a query, returning the data typed as per T
/// </summary> /// </summary>
/// <remarks>the dynamic param may seem a bit odd, but this works around a major usability issue in vs, if it is Object vs completion gets annoying. Eg type new [space] get new object</remarks> /// <remarks>the dynamic param may seem a bit odd, but this works around a major usability issue in vs, if it is Object vs completion gets annoying. Eg type new [space] get new object</remarks>
/// <returns>A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is /// <returns>A single instance of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is
/// created per row, and a direct column-name===member-name mapping is assumed (case insensitive). /// created per row, and a direct column-name===member-name mapping is assumed (case insensitive).
/// </returns> /// </returns>
public static T QuerySingleOrDefault<T>(this IDbConnection cnn, CommandDefinition command) public static T QuerySingleOrDefault<T>(this IDbConnection cnn, CommandDefinition command)
...@@ -1970,6 +1974,9 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj ...@@ -1970,6 +1974,9 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj
} }
/// <summary>
/// OBSOLETE: For internal usage only. Sanitizes the paramter value with proper type casting.
/// </summary>
[Obsolete(ObsoleteInternalUsageOnly, false)] [Obsolete(ObsoleteInternalUsageOnly, false)]
public static object SanitizeParameterValue(object value) public static object SanitizeParameterValue(object value)
{ {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
"dependencies": { "dependencies": {
}, },
"buildOptions": { "buildOptions": {
"xmlDoc": true,
"warningsAsErrors": true "warningsAsErrors": true
}, },
"frameworks": { "frameworks": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment