You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/framework/app-domains/build-single-file-assembly.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
title: "How to: Build a .NET Framework single-file assembly"
3
3
description: Explore how to build a single-file assembly in .NET. A single-file assembly can be a library (.dll) that targets .NET, or it can be an executable (.exe) file.
Copy file name to clipboardExpand all lines: docs/framework/app-domains/install-assembly-into-gac.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
title: "How to: Install an assembly into the global assembly cache"
3
3
description: Install an assembly into the global assembly cache (GAC) in .NET so it can be shared by many applications. Use Windows Installer or the GAC utility.
4
4
ms.date: 08/20/2019
5
+
ms.topic: how-to
5
6
helpviewer_keywords:
6
7
- "assemblies [.NET Framework], global assembly cache"
Copy file name to clipboardExpand all lines: docs/framework/data/adonet/implement-copytodatatable-where-type-not-a-datarow.md
+49-48Lines changed: 49 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,25 +2,26 @@
2
2
description: "Learn more about: How to: Implement CopyToDataTable<T> Where the Generic Type T Is Not a DataRow"
3
3
title: "How to: Implement CopyToDataTable<T> Where the Generic Type T Is Not a DataRow"
4
4
ms.date: "03/30/2017"
5
-
dev_langs:
5
+
ms.topic: how-to
6
+
dev_langs:
6
7
- "csharp"
7
8
- "vb"
8
9
ms.assetid: b27b52cf-6172-485f-a75c-70ff9c5a2bd4
9
10
---
10
11
# How to: Implement CopyToDataTable\<T> Where the Generic Type T Is Not a DataRow
11
12
12
-
The <xref:System.Data.DataTable> object is often used for data binding. The <xref:System.Data.DataTableExtensions.CopyToDataTable%2A> method takes the results of a query and copies the data into a <xref:System.Data.DataTable>, which can then be used for data binding. The <xref:System.Data.DataTableExtensions.CopyToDataTable%2A> methods, however, only operate on an <xref:System.Collections.Generic.IEnumerable%601> source where the generic parameter `T` is of type <xref:System.Data.DataRow>. Although this is useful, it does not allow tables to be created from a sequence of scalar types, from queries that project anonymous types, or from queries that perform table joins.
13
-
14
-
This topic describes how to implement two custom `CopyToDataTable<T>` extension methods that accept a generic parameter `T` of a type other than <xref:System.Data.DataRow>. The logic to create a <xref:System.Data.DataTable> from an <xref:System.Collections.Generic.IEnumerable%601> source is contained in the `ObjectShredder<T>` class, which is then wrapped in two overloaded `CopyToDataTable<T>` extension methods. The `Shred` method of the `ObjectShredder<T>` class returns the filled <xref:System.Data.DataTable> and accepts three input parameters: an <xref:System.Collections.Generic.IEnumerable%601> source, a <xref:System.Data.DataTable>, and a <xref:System.Data.LoadOption> enumeration. The initial schema of the returned <xref:System.Data.DataTable> is based on the schema of the type `T`. If an existing table is provided as input, the schema must be consistent with the schema of the type `T`. Each public property and field of the type `T` is converted to a <xref:System.Data.DataColumn> in the returned table. If the source sequence contains a type derived from `T`, the returned table schema is expanded for any additional public properties or fields.
15
-
16
-
For examples of using the custom `CopyToDataTable<T>` methods, see [Creating a DataTable From a Query](creating-a-datatable-from-a-query-linq-to-dataset.md).
17
-
18
-
### To implement the custom CopyToDataTable\<T> methods in your application
19
-
20
-
1. Implement the `ObjectShredder<T>` class to create a <xref:System.Data.DataTable> from an <xref:System.Collections.Generic.IEnumerable%601> source:
21
-
13
+
The <xref:System.Data.DataTable> object is often used for data binding. The <xref:System.Data.DataTableExtensions.CopyToDataTable%2A> method takes the results of a query and copies the data into a <xref:System.Data.DataTable>, which can then be used for data binding. The <xref:System.Data.DataTableExtensions.CopyToDataTable%2A> methods, however, only operate on an <xref:System.Collections.Generic.IEnumerable%601> source where the generic parameter `T` is of type <xref:System.Data.DataRow>. Although this is useful, it does not allow tables to be created from a sequence of scalar types, from queries that project anonymous types, or from queries that perform table joins.
14
+
15
+
This topic describes how to implement two custom `CopyToDataTable<T>` extension methods that accept a generic parameter `T` of a type other than <xref:System.Data.DataRow>. The logic to create a <xref:System.Data.DataTable> from an <xref:System.Collections.Generic.IEnumerable%601> source is contained in the `ObjectShredder<T>` class, which is then wrapped in two overloaded `CopyToDataTable<T>` extension methods. The `Shred` method of the `ObjectShredder<T>` class returns the filled <xref:System.Data.DataTable> and accepts three input parameters: an <xref:System.Collections.Generic.IEnumerable%601> source, a <xref:System.Data.DataTable>, and a <xref:System.Data.LoadOption> enumeration. The initial schema of the returned <xref:System.Data.DataTable> is based on the schema of the type `T`. If an existing table is provided as input, the schema must be consistent with the schema of the type `T`. Each public property and field of the type `T` is converted to a <xref:System.Data.DataColumn> in the returned table. If the source sequence contains a type derived from `T`, the returned table schema is expanded for any additional public properties or fields.
16
+
17
+
For examples of using the custom `CopyToDataTable<T>` methods, see [Creating a DataTable From a Query](creating-a-datatable-from-a-query-linq-to-dataset.md).
18
+
19
+
### To implement the custom CopyToDataTable\<T> methods in your application
20
+
21
+
1. Implement the `ObjectShredder<T>` class to create a <xref:System.Data.DataTable> from an <xref:System.Collections.Generic.IEnumerable%601> source:
The preceding example assumes that the properties and fields of the `DataColumn` are not nullable value types. To handle properties and fields with nullable value types, use the following code:
26
27
@@ -32,47 +33,47 @@ The <xref:System.Data.DataTable> object is often used for data binding. The <xre
When an entity already exists in a data service, the WCF Data Services client library enables you to attach an object that represents the entity directly to the <xref:System.Data.Services.Client.DataServiceContext> without first executing a query. For more information, see [Updating the Data Service](updating-the-data-service-wcf-data-services.md).
17
-
18
-
The example in this topic uses the Northwind sample data service and autogenerated client data service classes. This service and the client data classes are created when you complete the [WCF Data Services quickstart](quickstart-wcf-data-services.md).
19
-
20
-
## Example
17
+
When an entity already exists in a data service, the WCF Data Services client library enables you to attach an object that represents the entity directly to the <xref:System.Data.Services.Client.DataServiceContext> without first executing a query. For more information, see [Updating the Data Service](updating-the-data-service-wcf-data-services.md).
18
+
19
+
The example in this topic uses the Northwind sample data service and autogenerated client data service classes. This service and the client data classes are created when you complete the [WCF Data Services quickstart](quickstart-wcf-data-services.md).
20
+
21
+
## Example
22
+
23
+
The following example shows how to create an existing `Customer` object that contains changes to be saved to the data service. The object is attached to the context and the <xref:System.Data.Services.Client.DataServiceContext.UpdateObject%2A> method is called to mark the attached object as <xref:System.Data.Services.Client.EntityStates.Modified> before the <xref:System.Data.Services.Client.DataServiceContext.SaveChanges%2A> method is called.
21
24
22
-
The following example shows how to create an existing `Customer` object that contains changes to be saved to the data service. The object is attached to the context and the <xref:System.Data.Services.Client.DataServiceContext.UpdateObject%2A> method is called to mark the attached object as <xref:System.Data.Services.Client.EntityStates.Modified> before the <xref:System.Data.Services.Client.DataServiceContext.SaveChanges%2A> method is called.
With WCF Data Services, you can bind Windows Presentation Foundation (WPF) elements such as a <xref:System.Windows.Controls.ListBox> or <xref:System.Windows.Controls.ComboBox> to an instance of <xref:System.Data.Services.Client.DataServiceCollection%601>, which handles the events raised by the controls to keep the <xref:System.Data.Services.Client.DataServiceContext> synchronized with changes made to data in the controls. For more information, see [Binding Data to Controls](binding-data-to-controls-wcf-data-services.md).
18
-
19
-
The example in this topic uses the Northwind sample data service and autogenerated client data service classes. This service and the client data classes are created when you complete the [WCF Data Services quickstart](quickstart-wcf-data-services.md).
20
-
21
-
## Example
18
+
With WCF Data Services, you can bind Windows Presentation Foundation (WPF) elements such as a <xref:System.Windows.Controls.ListBox> or <xref:System.Windows.Controls.ComboBox> to an instance of <xref:System.Data.Services.Client.DataServiceCollection%601>, which handles the events raised by the controls to keep the <xref:System.Data.Services.Client.DataServiceContext> synchronized with changes made to data in the controls. For more information, see [Binding Data to Controls](binding-data-to-controls-wcf-data-services.md).
19
+
20
+
The example in this topic uses the Northwind sample data service and autogenerated client data service classes. This service and the client data classes are created when you complete the [WCF Data Services quickstart](quickstart-wcf-data-services.md).
21
+
22
+
## Example
23
+
24
+
The following example is from the code-behind page for an Extensible Application Markup Language (XAML) page that defines the `SalesOrders` window in WPF. When the window is loaded, a <xref:System.Data.Services.Client.DataServiceCollection%601> is created based on the result of a query that returns customers, filtered by country/region. All of the pages of this paged result are loaded, along with the related orders, and are bound to the <xref:System.Windows.FrameworkElement.DataContext%2A> property of the <xref:System.Windows.Controls.StackPanel> that is the root layout control for the WPF window. For more information, see [Loading Deferred Content](loading-deferred-content-wcf-data-services.md).
22
25
23
-
The following example is from the code-behind page for an Extensible Application Markup Language (XAML) page that defines the `SalesOrders` window in WPF. When the window is loaded, a <xref:System.Data.Services.Client.DataServiceCollection%601> is created based on the result of a query that returns customers, filtered by country/region. All of the pages of this paged result are loaded, along with the related orders, and are bound to the <xref:System.Windows.FrameworkElement.DataContext%2A> property of the <xref:System.Windows.Controls.StackPanel> that is the root layout control for the WPF window. For more information, see [Loading Deferred Content](loading-deferred-content-wcf-data-services.md).
The following example is from the code-behind page for an Extensible Application Markup Language (XAML) page that defines the `SalesOrders` window in WPF. When the window is loaded, a <xref:System.Data.Services.Client.DataServiceCollection%601> is created based on the result of a query that returns customers with related objects, filtered by country/region. This result is bound to the <xref:System.Windows.FrameworkElement.DataContext%2A> property of the <xref:System.Windows.Controls.StackPanel> that is the root layout control for the WPF window.
The following example is from the code-behind page for an Extensible Application Markup Language (XAML) page that defines the `SalesOrders` window in WPF. When the window is loaded, a <xref:System.Data.Services.Client.DataServiceCollection%601> is created based on the result of a query that returns customers with related objects, filtered by country/region. This result is bound to the <xref:System.Windows.FrameworkElement.DataContext%2A> property of the <xref:System.Windows.Controls.StackPanel> that is the root layout control for the WPF window.
0 commit comments