Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivony committed Nov 21, 2012
1 parent 2609896 commit 1a963c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/Ivony.Data/DataSetExtensions.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public static IEnumerable<DataRowView> View( this DataTable table )
/// <typeparam name="T">列数据类型</typeparam> /// <typeparam name="T">列数据类型</typeparam>
/// <param name="table">数据对象</param> /// <param name="table">数据对象</param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<T> Column<T>( this DataTable table ) public static T[] Column<T>( this DataTable table )
{ {
return table.Rows.Cast<DataRow>().Select( item => item.Field<T>( 0 ) ); return table.Rows.Cast<DataRow>().Select( item => item.Field<T>( 0 ) ).ToArray();
} }


/// <summary> /// <summary>
Expand All @@ -42,9 +42,9 @@ public static IEnumerable<T> Column<T>( this DataTable table )
/// <param name="table">数据对象</param> /// <param name="table">数据对象</param>
/// <param name="columnName">列名</param> /// <param name="columnName">列名</param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<T> Column<T>( this DataTable table, string columnName ) public static T[] Column<T>( this DataTable table, string columnName )
{ {
return table.Rows.Cast<DataRow>().Select( item => item.Field<T>( columnName ) ); return table.Rows.Cast<DataRow>().Select( item => item.Field<T>( columnName ) ).ToArray();
} }




Expand Down
6 changes: 6 additions & 0 deletions Sources/Ivony.Data/LegacyExtensions.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@ public static DataRow ExecuteSingleRow( this DbUtility dbUtility, string templat
return dbUtility.FirstRow( template, args ); return dbUtility.FirstRow( template, args );
} }


public static T[] ExecuteSingleColumn<T>( this DbUtility dbUtility, string template, params object[] args )
{
return dbUtility.Data( template, args ).Column<T>();
}


} }
} }

0 comments on commit 1a963c3

Please sign in to comment.