Skip to content

Commit 4b122e4

Browse files
authored
Merge branch 'master' into gewarren-morelittllethings
2 parents 1983deb + 4306111 commit 4b122e4

File tree

63 files changed

+1394
-169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1394
-169
lines changed

docs/data-tools/create-a-simple-data-application-with-wpf-and-entity-framework-6.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,12 @@ This walkthough shows how to create a basic "forms over data" application in Vis
405405

406406
The code-behind is minimal except for the add and delete methods. Navigation is performed by calling methods on the View property of the CollectionViewSource. The DeleteOrderCommandHandler shows how to perform a cascade delete on an order. We have to first delete the Order_Details that are associated with it. The UpdateCommandHandler adds a new customer or order to the collection, or else just updates an existing customer or order with the changes that the user made in the text boxes.
407407

408-
1. Add these handler methods to the MainWindow class in MainWindow.xaml.cs. If your CollectionViewSource for the Customers table has a different name, then you will need to adjust the name in each of these methods:
408+
Add these handler methods to the MainWindow class in MainWindow.xaml.cs. If your CollectionViewSource for the Customers table has a different name, then you will need to adjust the name in each of these methods:
409409

410410
[!code-csharp[CommandHandlers#3](../data-tools/codesnippet/CSharp/CreateWPFDataApp/MainWindow.xaml.cs#3)]
411411

412-
2. Press **F5** to start debugging. You should see customer and order data populated in the grid, and the navigation buttons should work as expected. Click on "Commit" to add a new customer or order to the model after you have entered the data. Click on "Cancel" to back out of a new customer or new order form without saving the data. You can make edits to existing customers and orders directly in the text boxes, and those changes will be written to the model automatically.
412+
## Run the application
413+
Press **F5** to start debugging. You should see customer and order data populated in the grid, and the navigation buttons should work as expected. Click on "Commit" to add a new customer or order to the model after you have entered the data. Click on "Cancel" to back out of a new customer or new order form without saving the data. You can make edits to existing customers and orders directly in the text boxes, and those changes will be written to the model automatically.
413414

414415
## See Also
415416
[Visual Studio data tools for .NET](../data-tools/visual-studio-data-tools-for-dotnet.md) [Entity Framework Documentation](https://msdn.microsoft.com/en-us/data/ee712907.aspx)

docs/data-tools/create-and-configure-tableadapters.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Create and configure TableAdapters | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "09/01/2017"
55
ms.reviewer: ""
66
ms.suite: ""
77
ms.tgt_pltfrm: ""
@@ -14,8 +14,8 @@ helpviewer_keywords:
1414
- "data [Visual Studio], creating table adapters"
1515
ms.assetid: 08630d69-0d6c-4e8f-b42d-2922f45f8415
1616
caps.latest.revision: 28
17-
author: "mikeblome"
18-
ms.author: "mblome"
17+
author: "gewarren"
18+
ms.author: "gewarren"
1919
manager: "ghogen"
2020
translation.priority.ht:
2121
- "de-de"
@@ -42,31 +42,34 @@ TableAdapters provide communication between your application and a database. The
4242

4343
- Drag database objects from **Server Explorer** into the **Dataset Designer**.
4444

45-
You can create a new TableAdapter and configure it with a data source by dragging a TableAdapter from the Toolbox to an empty region in the **Dataset Designer** surface.
45+
You can also create a new TableAdapter and configure it with a data source by dragging a TableAdapter from the Toolbox to an empty region in the **Dataset Designer** surface.
4646

47-
For an introduction to TableAdapters, see [Fill datasets by using TableAdapters](../data-tools/fill-datasets-by-using-tableadapters.md).
47+
For an introduction to TableAdapters, see [Fill datasets by using TableAdapters](../data-tools/fill-datasets-by-using-tableadapters.md).
4848

49-
[!INCLUDE[note_settings_general](../data-tools/includes/note_settings_general_md.md)]
49+
[!INCLUDE[note_settings_general](../data-tools/includes/note_settings_general_md.md)]
5050

5151
## Use the TableAdapter Configuration Wizard
5252
Run the **TableAdapter Configuration Wizard** to create or edit TableAdapters and their associated DataTables. You can configure an existing TableAdapter by right-clicking on it in the **Dataset Designer**.
5353

5454
![raddata Table Adapter Configuration Wizard](../data-tools/media/raddata-table-adapter-configuration-wizard.png "raddata Table Adapter Configuration Wizard")
5555

56-
If you drag a new TableAdapter from the Toolbox when the **Dataset Designer** is in focus, the wizard prompts you to specify which data source the TableAdapter should connect to, and what kind of commands it should use to communicate with the database, SQL statements, or stored procedures. You won't see this if you are configuring a TableAdapter that is already associated with a data source.
56+
If you drag a new TableAdapter from the Toolbox when the **Dataset Designer** is in focus, the wizard starts and prompts you to specify which data source the TableAdapter should connect to. On the next page, the wizard asks what kind of commands it should use to communicate with the database, either SQL statements or stored procedures. (You won't see this if you are configuring a TableAdapter that is already associated with a data source.)
5757

58-
- Using the **Create methods to send updates directly to the database** option is equivalent to setting the `GenerateDBDirectMethods` property to true. The option is unavailable when the original SQL statement does not provide enough information or the query is not an updateable query. This situation can occur, for example, in **JOIN** queries and queries that return a single (scalar) value.
58+
- You have the option to create a new stored procedure in the underlying database if you have the correct permissions for the database. If you don't have these permissions, this won't be an option.
5959

60-
- You have the option to create a new stored procedure in the underlying database if you have the correct permissions for the database. If you don't have these permissions, this won't be an option.
60+
- You can also choose to run existing stored procedures for the **SELECT**, **INSERT**, **UPDATE**, and **DELETE** commands of the TableAdapter. The stored procedure that's assigned to the **Update** command, for example, is run when the `TableAdapter.Update()` method is called.
6161

62-
- You can also choose to run existing stored procedures for the **SELECT**, **INSERT**, **UPDATE**, and **DELETE** commands of the TableAdapter. The stored procedure that's assigned to the **Update** command, for example, is run when the `TableAdapter.Update()` method is called.
62+
Map parameters from the selected stored procedure to the corresponding columns in the data table. For example, if your stored procedure accepts a parameter named `@CompanyName` that it passes to the `CompanyName` column in the table, set the **Source Column** of the `@CompanyName` parameter to `CompanyName`.
6363

64-
Map parameters from the selected stored procedure to the corresponding columns in the data table. For example, if your stored procedure accepts a parameter named `@CompanyName` that it passes to the `CompanyName` column in the table, set the **Source Column** of the `@CompanyName` parameter to `CompanyName`.
64+
> [!NOTE]
65+
> The stored procedure that's assigned to the SELECT command is run by calling the method of the TableAdapter that you name in the next step of the wizard. The default method is `Fill`, so the code that's typically used to run the SELECT procedure is `TableAdapter.Fill(tableName)`. If you change the default name from `Fill`, substitute `Fill` with the name you assign, and replace "TableAdapter" with the actual name of the TableAdapter (for example, `CustomersTableAdapter`).
6566
66-
> [!NOTE]
67-
> The stored procedure that's assigned to the SELECT command is run by calling the method of the TableAdapter that you name in the next step of the wizard. The default method is `Fill`, so the code that's typically used to run the SELECT procedure is `TableAdapter.Fill(tableName)`. If you change the default name from `Fill`, substitute `Fill` with the name you assign, and replace "TableAdapter" with the actual name of the TableAdapter (for example, `CustomersTableAdapter`).
67+
- Selecting the **Create methods to send updates directly to the database** option is equivalent to setting the `GenerateDBDirectMethods` property to true. The option is unavailable when the original SQL statement does not provide enough information or the query is not an updateable query. This situation can occur, for example, in **JOIN** queries and queries that return a single (scalar) value.
6868

69-
- The **Advanced Options** in the wizard enable you to generate INSERT, UPDATE, and DELETE statements based on the SELECT statement that's defined on the **Generate SQL statements** page. Use optimistic concurrency, and specify whether to refresh the data table after INSERT and UPDATE statements are run.
69+
The **Advanced Options** in the wizard enable you to:
70+
- Generate INSERT, UPDATE, and DELETE statements based on the SELECT statement that's defined on the **Generate SQL statements** page
71+
- Use optimistic concurrency
72+
- Specify whether to refresh the data table after INSERT and UPDATE statements are run
7073

7174
## Configure a TableAdapter's Fill method
7275
Sometimes you might want to change the schema of the TableAdapter's table. To do this, you modify the TableAdapter's primary `Fill` method. TableAdapters are created with a primary `Fill` method that defines the schema of the associated data table. The primary `Fill` method is based on the query or stored procedure you entered when you originally configured the TableAdapter. It's the first (topmost) method under the data table in the DataSet Designer.

docs/data-tools/create-parameterized-tableadapter-queries.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,25 @@ A parameterized query returns data that meets the conditions of a WHERE clause w
8989

9090
A control to input the parameter and a **Load** button are added to the form in a <xref:System.Windows.Forms.ToolStrip> control.
9191

92-
TableAdapter parameters can be assigned null values when you want to query for records that have no current value. For example, consider the following query that has a `ShippedDate` parameter in its `WHERE` clause:
92+
#### Querying for null values
93+
TableAdapter parameters can be assigned null values when you want to query for records that have no current value. For example, consider the following query that has a `ShippedDate` parameter in its `WHERE` clause:
9394

94-
`SELECT CustomerID, OrderDate, ShippedDate`
95-
96-
`FROM Orders`
97-
98-
`WHERE (ShippedDate = @ShippedDate) OR`
99-
100-
`(ShippedDate IS NULL)`
95+
```sql
96+
SELECT CustomerID, OrderDate, ShippedDate
97+
FROM Orders
98+
WHERE (ShippedDate = @ShippedDate) OR (ShippedDate IS NULL)
99+
```
101100

102101
If this were a query on a TableAdapter, you could query for all orders that have not been shipped with the following code:
103102

104103
[!code-csharp[VbRaddataTableAdapters#8](../data-tools/codesnippet/CSharp/create-parameterized-tableadapter-queries_1.cs)]
105104
[!code-vb[VbRaddataTableAdapters#8](../data-tools/codesnippet/VisualBasic/create-parameterized-tableadapter-queries_1.vb)]
106-
107-
#### To enable a query to accept null values
108-
105+
106+
To enable a query to accept null values:
107+
109108
1. In the **Dataset Designer**, select the TableAdapter query that needs to accept null parameter values.
110109

111-
2. In the **Properties** window, select **Parameters**.Then press the ellipsis (**...**) button to open the **Parameters Collection Editor**.
110+
2. In the **Properties** window, select **Parameters**, then click the ellipsis (**...**) button to open the **Parameters Collection Editor**.
112111

113112
3. Select the parameter that allows null values and set the **AllowDbNull** property to `true`.
114113

docs/data-tools/directly-access-the-database-with-a-tableadapter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ In addition to the `InsertCommand`, `UpdateCommand`, and `DeleteCommand`, TableA
5252

5353
#### To insert new records directly into a database
5454

55-
- Call the TableAdapter's `Insert` method, passing in the values for each column as parameters. The following procedure uses the `Region` table in the Northwind databaseas an example.
55+
- Call the TableAdapter's `Insert` method, passing in the values for each column as parameters. The following procedure uses the `Region` table in the Northwind database as an example.
5656

5757
> [!NOTE]
5858
> If you do not have an instance available, instantiate the TableAdapter that you want to use.

docs/data-tools/entity-data-model-tools-in-visual-studio.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ translation.priority.mt:
3030
# Entity Data Model Tools in Visual Studio
3131
Entity Framework is an object-relational mapping technology that enables .NET developers to work with relational data by using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write. Entity Framework is the recommended object-relational mapping (ORM) modeling technology for new .NET applications.
3232

33-
As of March 2016, the most current released version is [Entity Framework 6](https://msdn.microsoft.com/en-us/data/ef) . [Entity Framework 7](https://docs.efproject.net/en/latest/) is in pre-release.
34-
35-
[!INCLUDE[adonet_edm](../data-tools/includes/adonet_edm_md.md)] Tools are designed to help you build [!INCLUDE[adonet_ef](../data-tools/includes/adonet_ef_md.md)] applications. The complete documentation for [!INCLUDE[adonet_edm](../data-tools/includes/adonet_edm_md.md)] Tools is here: [Entity Framework](https://msdn.microsoft.com/en-us/data/jj590134).
33+
[!INCLUDE[adonet_edm](../data-tools/includes/adonet_edm_md.md)] Tools are designed to help you build Entity Framework (EF) applications. The complete documentation for Entity Framework is here: [EF Core and EF 6](https://docs.microsoft.com/en-us/ef/).
3634

3735
With [!INCLUDE[adonet_edm](../data-tools/includes/adonet_edm_md.md)] Tools, you can create a *conceptual model* from an existing database and then graphically visualize and edit your conceptual model. Or, you can graphically create a conceptual model first, and then generate a database that supports your model. In either case, you can automatically update your model when the underlying database changes and automatically generate object-layer code for your application. Database generation and object-layer code generation are customizable.
3836

docs/data-tools/fill-datasets-by-using-tableadapters.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ A TableAdapter component fills a dataset with data from the database, based on
7676
## TableAdapter queries
7777
![TableAdapter with multiple queries](../data-tools/media/tableadapter.gif "TableAdapter")
7878

79-
TableAdapters can contain multiple queries to fill their associated data tables. You can define as many queries for a TableAdapter as your application requires, as long as each query returns data that conforms to the same schema as its associated data table. This capability enable a TableAdapter to load different results based on differing criteria.
79+
TableAdapters can contain multiple queries to fill their associated data tables. You can define as many queries for a TableAdapter as your application requires, as long as each query returns data that conforms to the same schema as its associated data table. This capability enables a TableAdapter to load different results based on differing criteria.
8080

8181
For example, if your application contains a table with customer names, you can create a query that fills the table with every customer name that begins with a certain letter, and another that fills the table with all customers that are located in the same state. To fill a `Customers` table with customers in a given state, you can create a `FillByState` query that takes a parameter for the state value as follows: `SELECT * FROM Customers WHERE State = @State`. You run the query by calling the `FillByState` method and passing in the parameter value like this: `CustomerTableAdapter.FillByState("WA")`.
8282

@@ -86,7 +86,7 @@ A TableAdapter component fills a dataset with data from the database, based on
8686
By default, every time you run a query to fill a TableAdapter's data table, the existing data is cleared, and only the results of the query are loaded into the table. Set the TableAdapter's `ClearBeforeFill` property to `false` if you want to add or merge the data that's returned from a query to the existing data in a data table. Regardless of whether you clear the data, you need to explicitly send updates back to the database, if you want to persist them. So remember to save any changes to the data in the table before running another query that fills the table. For more information, see [Update data by using a TableAdapter](../data-tools/update-data-by-using-a-tableadapter.md).
8787

8888
## TableAdapter inheritance
89-
TableAdapters extend the functionality of standard data adapters by encapsulating a configured <xref:System.Data.Common.DataAdapter> class?qualifyHint=False&autoUpgrade=True. By default, the TableAdapter inherits from the <xref:System.ComponentModel.Component> class and can't be cast to the <xref:System.Data.Common.DataAdapter> class. Casting a TableAdapter to the <xref:System.Data.Common.DataAdapter> class results in a <xref:System.InvalidCastException> error?qualifyHint=False&autoUpgrade=True. To change the base class of a TableAdapter, you can type a class that derives from <xref:System.ComponentModel.Component> in the **Base Class** property of the TableAdapter in the **Dataset Designer**.
89+
TableAdapters extend the functionality of standard data adapters by encapsulating a configured <xref:System.Data.Common.DataAdapter> class. By default, the TableAdapter inherits from the <xref:System.ComponentModel.Component> class and can't be cast to the <xref:System.Data.Common.DataAdapter> class. Casting a TableAdapter to the <xref:System.Data.Common.DataAdapter> class results in an <xref:System.InvalidCastException> error. To change the base class of a TableAdapter, you can specify a class that derives from <xref:System.ComponentModel.Component> in the **Base Class** property of the TableAdapter in the **Dataset Designer**.
9090

9191
## TableAdapter methods and properties
9292
The TableAdapter class is not part of the [!INCLUDE[dnprdnshort](../code-quality/includes/dnprdnshort_md.md)]. This means you can't look it up in the documentation or the **Object Browser**. It's created at design time when you use one of the wizards mentioned earlier. The name that's assigned to a TableAdapter when you create it is based on the name of the table you are working with. For example, when you create a TableAdapter based on a table in a database named `Orders`, the TableAdapter is named `OrdersTableAdapter`. The class name of the TableAdapter can be changed using the **Name** property in the **Dataset Designer**.
@@ -115,7 +115,7 @@ A TableAdapter component fills a dataset with data from the database, based on
115115
If you don't want to create these direct methods, set the TableAdapter's **GenerateDbDirectMethods** property to `false` (in the **Properties** window). Additional queries that are added to the TableAdapter are standalone queries — they don't generate these methods.
116116

117117
## TableAdapter support for nullable types
118-
TableAdapters support nullable types `Nullable(Of T)` and `T?`. For more information about nullable types in Visual Basic, see [Nullable Value Types](/dotnet/visual-basic/programming-guide/language-features/data-types/nullable-value-types.md). For more information about nullable types in C#, see [Using Nullable Types](/dotnet/csharp/programming-guide/nullable-types/using-nullable-types).
118+
TableAdapters support nullable types `Nullable(Of T)` and `T?`. For more information about nullable types in Visual Basic, see [Nullable Value Types](/dotnet/visual-basic/programming-guide/language-features/data-types/nullable-value-types). For more information about nullable types in C#, see [Using Nullable Types](/dotnet/csharp/programming-guide/nullable-types/using-nullable-types).
119119

120120
<a name="tableadaptermanager-reference"></a>
121121

0 commit comments

Comments
 (0)