Esempio n. 1
0
 /// <summary>
 /// This method provides access to the values in each of the columns in a given row.
 /// This method makes casts unnecessary when accessing columns.
 /// Additionally, Field supports nullable types and maps automatically between DBNull and
 /// Nullable when the generic type is nullable.
 /// </summary>
 /// <param name="row">The input DataRow</param>
 /// <param name="columnIndex">The input ordinal specifying which row value to retrieve.</param>
 /// <param name="version">The DataRow version for which row value to retrieve.</param>
 /// <returns>The DataRow value for the column specified.</returns>
 public static T Field <T>(this DataRow row, int columnIndex, DataRowVersion version)
 {
     DataSetUtil.CheckArgumentNull(row, nameof(row));
     return(UnboxT <T> .s_unbox(row[columnIndex, version]));
 }
Esempio n. 2
0
 /// <summary>
 /// This method sets a new value for the specified column for the DataRow it�s called on.
 /// </summary>
 /// <param name="row">The input DataRow.</param>
 /// <param name="column">The input DataColumn specifying which row value to retrieve.</param>
 /// <param name="value">The new row value for the specified column.</param>
 public static void SetField <T>(this DataRow row, DataColumn column, T value)
 {
     DataSetUtil.CheckArgumentNull(row, nameof(row));
     row[column] = (object)value ?? DBNull.Value;
 }
Esempio n. 3
0
 /// <summary>
 /// This method provides access to the values in each of the columns in a given row.
 /// This method makes casts unnecessary when accessing columns.
 /// Additionally, Field supports nullable types and maps automatically between DBNull and
 /// Nullable when the generic type is nullable.
 /// </summary>
 /// <param name="row">The input DataRow</param>
 /// <param name="column">The input DataColumn specifying which row value to retrieve.</param>
 /// <returns>The DataRow value for the column specified.</returns>
 public static T Field <T>(this DataRow row, DataColumn column)
 {
     DataSetUtil.CheckArgumentNull(row, nameof(row));
     return(UnboxT <T> .s_unbox(row[column]));
 }
 /// <summary>
 /// This method provides access to the values in each of the columns in a given row.
 /// This method makes casts unnecessary when accessing columns.
 /// Additionally, Field supports nullable types and maps automatically between DBNull and
 /// Nullable when the generic type is nullable.
 /// </summary>
 /// <param name="row">The input DataRow</param>
 /// <param name="columnName">The input column name specifying which row value to retrieve.</param>
 /// <param name="version">The DataRow version for which row value to retrieve.</param>
 /// <returns>The DataRow value for the column specified.</returns>
 public static T?Field <T>(this DataRow row, string columnName, DataRowVersion version)
 {
     DataSetUtil.CheckArgumentNull(row, nameof(row));
     return(UnboxT <T> .s_unbox(row[columnName, version]));
 }
Esempio n. 5
0
 /// <summary>
 /// This method returns a IEnumerable of TRow.
 /// </summary>
 /// <param name="source">The source DataTable to make enumerable.</param>
 /// <returns>IEnumerable of datarows.</returns>
 public static EnumerableRowCollection <TRow> AsEnumerable <TRow>(this TypedTableBase <TRow> source) where TRow : DataRow
 {
     DataSetUtil.CheckArgumentNull(source, nameof(source));
     return(new EnumerableRowCollection <TRow>(source as DataTable));
 }
Esempio n. 6
0
 /// <summary>
 /// This method sets a new value for the specified column for the DataRow it�s called on.
 /// </summary>
 /// <param name="row">The input DataRow.</param>
 /// <param name="columnIndex">The input ordinal specifying which row value to set.</param>
 /// <param name="value">The new row value for the specified column.</param>
 public static void SetField <T>(this DataRow row, int columnIndex, T value)
 {
     DataSetUtil.CheckArgumentNull(row, "row");
     row[columnIndex] = (object)value ?? DBNull.Value;
 }
 /// <summary>
 /// This method sets a new value for the specified column for the DataRow it's called on.
 /// </summary>
 /// <param name="row">The input DataRow.</param>
 /// <param name="columnName">The input column name specifying which row value to retrieve.</param>
 /// <param name="value">The new row value for the specified column.</param>
 public static void SetField <T>(this DataRow row, string columnName, T?value)
 {
     DataSetUtil.CheckArgumentNull(row, nameof(row));
     row[columnName] = (object?)value ?? DBNull.Value;
 }
Esempio n. 8
0
 /// <summary>
 ///  This method provides access to the values in each of the columns in a given row.
 ///  This method makes casts unnecessary when accessing columns.
 ///  Additionally, Field supports nullable types and maps automatically between DBNull and
 ///  Nullable when the generic type is nullable.
 /// </summary>
 /// <param name="row">
 ///   The input DataRow
 /// </param>
 /// <param name="columnName">
 ///   The input column name specificy which row value to retrieve.
 /// </param>
 /// <returns>
 ///   The DataRow value for the column specified.
 /// </returns>
 public static T Field <T>(this DataRow row, string columnName)
 {
     DataSetUtil.CheckArgumentNull(row, "row");
     return(UnboxT <T> .Unbox(row[columnName]));
 }
Esempio n. 9
0
 /// <summary>
 ///  This method provides access to the values in each of the columns in a given row.
 ///  This method makes casts unnecessary when accessing columns.
 ///  Additionally, Field supports nullable types and maps automatically between DBNull and
 ///  Nullable when the generic type is nullable.
 /// </summary>
 /// <param name="row">
 ///   The input DataRow
 /// </param>
 /// <param name="columnIndex">
 ///   The input ordinal specificy which row value to retrieve.
 /// </param>
 /// <returns>
 ///   The DataRow value for the column specified.
 /// </returns>
 public static T Field <T>(this DataRow row, int columnIndex)
 {
     DataSetUtil.CheckArgumentNull(row, "row");
     return(UnboxT <T> .Unbox(row[columnIndex]));
 }
Esempio n. 10
0
 /// <summary>
 ///  This method provides access to the values in each of the columns in a given row.
 ///  This method makes casts unnecessary when accessing columns.
 ///  Additionally, Field supports nullable types and maps automatically between DBNull and
 ///  Nullable when the generic type is nullable.
 /// </summary>
 /// <param name="row">
 ///   The input DataRow
 /// </param>
 /// <param name="column">
 ///   The input DataColumn specificy which row value to retrieve.
 /// </param>
 /// <param name="version">
 ///   The DataRow version for which row value to retrieve.
 /// </param>
 /// <returns>
 ///   The DataRow value for the column specified.
 /// </returns>
 public static T Field <T>(this DataRow row, DataColumn column, DataRowVersion version)
 {
     DataSetUtil.CheckArgumentNull(row, "row");
     return(UnboxT <T> .Unbox(row[column, version]));
 }
Esempio n. 11
0
 /// <summary>
 /// This method takes an input sequence of DataRows and produces a DataTable object
 /// with copies of the source rows.
 /// Also note that this will cause the rest of the query to execute at this point in time
 /// (e.g. there is no more delayed execution after this sequence operator).
 /// </summary>
 /// <param name="source">The input sequence of DataRows</param>
 /// <returns>DataTable containing copies of the source DataRows. Properties for the DataTable table will be taken from first DataRow in the source.</returns>
 /// <exception cref="ArgumentNullException">if source is null</exception>
 /// <exception cref="InvalidOperationException">if source is empty</exception>
 public static DataTable CopyToDataTable <T>(this IEnumerable <T> source)
     where T : DataRow
 {
     DataSetUtil.CheckArgumentNull(source, nameof(source));
     return(LoadTableFromEnumerable(source, table: null, options: null, errorHandler: null));
 }
Esempio n. 12
0
 /// <summary>
 /// This method returns a IEnumerable of Datarows.
 /// </summary>
 /// <param name="source">The source DataTable to make enumerable.</param>
 /// <returns>IEnumerable of datarows.</returns>
 public static EnumerableRowCollection <DataRow> AsEnumerable(this DataTable source)
 {
     DataSetUtil.CheckArgumentNull(source, nameof(source));
     return(new EnumerableRowCollection <DataRow>(source));
 }
 /// <summary>
 /// Creates a LinqDataView from EnumerableDataTable
 /// </summary>
 /// <typeparam name="T">Type of the row in the table. Must inherit from DataRow</typeparam>
 /// <param name="source">The enumerable-datatable over which view must be created.</param>
 /// <returns>Generated LinkDataView of type T</returns>
 public static DataView AsDataView <T>(this EnumerableRowCollection <T> source) where T : DataRow
 {
     DataSetUtil.CheckArgumentNull <EnumerableRowCollection <T> >(source, nameof(source));
     return(source.GetLinqDataView());
 }
 /// <summary>
 /// Creates a LinkDataView of DataRow over the input table.
 /// </summary>
 /// <param name="table">DataTable that the view is over.</param>
 /// <returns>An instance of LinkDataView.</returns>
 public static DataView AsDataView(this DataTable table)
 {
     DataSetUtil.CheckArgumentNull <DataTable>(table, nameof(table));
     return(new LinqDataView(table, null));
 }