[Mono-bugs] [Bug 591397] System.Data.DataTableExtensions.CopyToDataTable(Of T) returns 0 Rows

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Mar 26 20:27:59 EDT 2010


http://bugzilla.novell.com/show_bug.cgi?id=591397

http://bugzilla.novell.com/show_bug.cgi?id=591397#c5


--- Comment #5 from Tony Fish <tonyvfish at googlemail.com> 2010-03-27 00:27:58 UTC ---
Miguel
Just to be completely clear about what I'm doing.  The only part of MONO I'm
using is the DataExtensions.  Everything else is .NET 2  .I'm doing this
because .Net 2.0 does not include LINQ which I need, but can not use .Net 3.x. 
So I use an open source implementation to allow me to do LINQ over objects
called LinqBridge.  However LinqBridge (LINQ over objects) does not include the
extension methods needed for working with datatables dat rows etc.  This is why
I use MONO DataExtensions to  provide this functionality

When the code calls the extension method o.CopyToDataTable()

DatatableExtensions.cs eventually invokes 

public static void CopyToDataTable<T> (this IEnumerable<T> source, DataTable
table, LoadOption options, FillErrorEventHandler errorHandler)
            where T : DataRow
        {
            var reader = new RowEnumerableDataReader (source, 0);
            table.Load (reader, options, errorHandler);
        }

Now keep in mind the code line   table.Load (reader, options, errorHandler);
When the table is a .NET version 2, the first call made by the table on the
reader is the sub  
public void Close ()
        {
            e = null;
        }
of RowEnumerableDataReader.cs

This is why I added this line to the contructor
//tf Added cos isClosed is called fist by MS
            _e = ((IEnumerable)this._source).GetEnumerator();

If e does not get set in the constructot , the .NET table thinks the reader is
closed and returns an un populated table.

So I've taken a look at your patched constructor now on CVS and added 1 line
back. ( please see attachment ). RowEnumerableDataReader.cs will now be more
compatible with .NET as well as MONO

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list