- 
                Notifications
    You must be signed in to change notification settings 
- Fork 6.1k
Closed
Labels
Milestone
Description
This does not work with nullable types unless you change the code:
            DataColumn dc = table.Columns.Contains(p.Name) ? table.Columns[p.Name] : table.Columns.Add(p.Name, p.PropertyType);
with:
DataColumn dc = table.Columns.Contains(p.Name) ? table.Columns[p.Name] : table.Columns.Add(p.Name, Nullable.GetUnderlyingType(p.PropertyType) ?? p.PropertyType);
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: ebd6b5c5-3266-0a2f-e535-d983fc0e5610
- Version Independent ID: 98956973-e9bc-c8a1-c356-1505d318a129
- Content: How to: Implement CopyToDataTable Where the Generic Type T Is Not a DataRow
- Content Source: docs/framework/data/adonet/implement-copytodatatable-where-type-not-a-datarow.md
- Service: unspecified
- Product: dotnet-framework
- GitHub Login: @douglaslMS
- Microsoft Alias: douglasl
pietervdheijden