Skip to content

Review and fix TODO code snippet references (docs 2) #2023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ With [!INCLUDE[ssAstoria](../../../../includes/ssastoria-md.md)], you can create

The behaviors of the data service are defined by the members of the <xref:System.Data.Services.DataServiceConfiguration> class, and by members of the <xref:System.Data.Services.DataServiceBehavior> class, which is accessed from the <xref:System.Data.Services.DataServiceConfiguration.DataServiceBehavior%2A> property of the <xref:System.Data.Services.DataServiceConfiguration> class. The <xref:System.Data.Services.DataServiceConfiguration> class is supplied to the `InitializeService` method that is implemented by the data service, as in the following implementation of a Northwind data service:

<!-- TODO: review snippet reference [!CODE [Astoria NorthwindService#DataServiceConfigComplete](Astoria NorthwindService#DataServiceConfigComplete)] -->
[!code-csharp[Astoria Northwind Service#DataServiceConfigComplete](../../../../samples/snippets/csharp/VS_Snippets_Misc/Astoria Northwind Service/cs/northwind.svc.cs#dataserviceconfigcomplete)]
[!code-vb[Astoria Northwind Service#DataServiceConfigComplete](../../../../samples/snippets/visualbasic/VS_Snippets_Misc/Astoria Northwind Service/vb/northwind.svc.vb#dataserviceconfigcomplete)]

## Data Service Configuration Settings
The <xref:System.Data.Services.DataServiceConfiguration> class enables you to specify the following data service behaviors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ When you use the [!INCLUDE[ssAstoria](../../../../includes/ssastoria-md.md)] cli
> [!NOTE]
> When a data service requires you to manually set the message header for every request, consider registering the handler for the <xref:System.Data.Services.Client.DataServiceContext.SendingRequest> event by overriding the `OnContextCreated` partial method in the entity container that represents the data service, which in this case is `NorthwindEntities`.

<!-- TODO: review snippet reference [!CODE [Astoria NorthwindClient#RegisterHeadersQuery](Astoria NorthwindClient#RegisterHeadersQuery)] -->
[!code-csharp[Astoria Northwind Client#RegisterHeadersQuery](../../../../samples/snippets/csharp/VS_Snippets_Misc/Astoria Northwind Client/cs/source.cs#registerheadersquery)]
[!code-vb[Astoria Northwind Client#RegisterHeadersQuery](../../../../samples/snippets/visualbasic/VS_Snippets_Misc/Astoria Northwind Client/vb/source.vb#registerheadersquery)]

## Example
The following method handles the <xref:System.Data.Services.Client.DataServiceContext.SendingRequest> event and adds an Authentication header to the request.

<!-- TODO: review snippet reference [!CODE [Astoria NorthwindClient#OnSendingRequest](Astoria NorthwindClient#OnSendingRequest)] -->
[!code-csharp[Astoria Northwind Client#OnSendingRequest](../../../../samples/snippets/csharp/VS_Snippets_Misc/Astoria Northwind Client/cs/source.cs#onsendingrequest)]
[!code-vb[Astoria Northwind Client#OnSendingRequest](../../../../samples/snippets/visualbasic/VS_Snippets_Misc/Astoria Northwind Client/vb/source.vb#onsendingrequest)]

## See Also
[Securing WCF Data Services](../../../../docs/framework/data/wcf/securing-wcf-data-services.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The [!INCLUDE[ssAstoria](../../../../includes/ssastoria-md.md)] client library e

The following query, when it is executed, returns all `Customers` entities in the Northwind data service:

[!code-csharp[Astoria Northwind Client#GetAllCustomersSpecific](../../../../samples/snippets/csharp/VS_Snippets_Misc/astoria northwind client/cs/source.cs#getallcustomersspecific)]
[!code-csharp[Astoria Northwind Client#GetAllCustomersSpecific](../../../../samples/snippets/csharp/VS_Snippets_Misc/astoria northwind client/cs/source.cs#getallcustomersspecific)]
[!code-vb[Astoria Northwind Client#GetAllCustomersSpecific](../../../../samples/snippets/visualbasic/VS_Snippets_Misc/astoria northwind client/vb/source.vb#getallcustomersspecific)]

For more information, see [How to: Execute Data Service Queries](../../../../docs/framework/data/wcf/how-to-execute-data-service-queries-wcf-data-services.md).
Expand All @@ -51,7 +51,8 @@ The [!INCLUDE[ssAstoria](../../../../includes/ssastoria-md.md)] client library e
## LINQ Queries
Because the <xref:System.Data.Services.Client.DataServiceQuery%601> class implements the <xref:System.Linq.IQueryable%601> interface defined by LINQ, the [!INCLUDE[ssAstoria](../../../../includes/ssastoria-md.md)] client library is able to transform LINQ queries against entity set data into a URI that represents a query expression evaluated against a data service resource. The following example is a LINQ query that is equivalent to the previous <xref:System.Data.Services.Client.DataServiceQuery%601> that returns `Orders` that have a freight cost of more than $30 and orders the results by the freight cost:

<!-- TODO: review snippet reference [!CODE [Astoria NorthwindClient#AddQueryOptionsLinqSpecific](Astoria NorthwindClient#AddQueryOptionsLinqSpecific)] -->
[!code-csharp[Astoria Northwind Client#AddQueryOptionsLinqSpecific](../../../../samples/snippets/csharp/VS_Snippets_Misc/astoria northwind client/cs/source.cs#addqueryoptionslinqspecific)]
[!code-vb[Astoria Northwind Client#AddQueryOptionsLinqSpecific](../../../../samples/snippets/visualbasic/VS_Snippets_Misc/astoria northwind client/vb/source.vb#addqueryoptionslinqspecific)]

This LINQ query is translated into the following query URI that is executed against the Northwind-based [quickstart](../../../../docs/framework/data/wcf/quickstart-wcf-data-services.md) data service:

Expand All @@ -67,7 +68,8 @@ http://localhost:12345/Northwind.svc/Orders?Orderby=ShippedDate&?filter=Freight
## Adding Query Options
Data service queries support all the query options that [!INCLUDE[ssAstoria](../../../../includes/ssastoria-md.md)]s provides. You call the <xref:System.Data.Services.Client.DataServiceQuery%601.AddQueryOption%2A> method to append query options to a <xref:System.Data.Services.Client.DataServiceQuery%601> instance. <xref:System.Data.Services.Client.DataServiceQuery%601.AddQueryOption%2A> returns a new <xref:System.Data.Services.Client.DataServiceQuery%601> instance that is equivalent to the original query but with the new query option set. The following query, when executed, returns `Orders` that are filtered by the `Freight` value and ordered by the `OrderID`, descending:

<!-- TODO: review snippet reference [!CODE [Astoria NorthwindClient#AddQueryOptionsSpecific](Astoria NorthwindClient#AddQueryOptionsSpecific)] -->
[!code-csharp[Astoria Northwind Client#AddQueryOptionsSpecific](../../../../samples/snippets/csharp/VS_Snippets_Misc/astoria northwind client/cs/source.cs#addqueryoptionsspecific)]
[!code-vb[Astoria Northwind Client#AddQueryOptionsSpecific](../../../../samples/snippets/visualbasic/VS_Snippets_Misc/astoria northwind client/vb/source.vb#addqueryoptionsspecific)]

You can use the `$orderby` query option to both order and filter a query based on a single property, as in the following example that filters and orders the returned `Orders` objects based on the value of the `Freight` property:

Expand All @@ -85,7 +87,8 @@ http://localhost:12345/Northwind.svc/Orders?Orderby=ShippedDate&?filter=Freight
## Client versus Server Execution
The client executes a query in two parts. Whenever possible, expressions in a query are first evaluated on the client, and then a URI-based query is generated and sent to the data service for evaluation against data in the service. Consider the following LINQ query:

<!-- TODO: review snippet reference [!CODE [Astoria NorthwindClient#LinqQueryClientEvalSpecific](Astoria NorthwindClient#LinqQueryClientEvalSpecific)] -->
[!code-csharp[Astoria Northwind Client#LinqQueryClientEvalSpecific](../../../../samples/snippets/csharp/VS_Snippets_Misc/astoria northwind client/cs/source.cs#linqqueryclientevalspecific)]
[!code-vb[Astoria Northwind Client#LinqQueryClientEvalSpecific](../../../../samples/snippets/visualbasic/VS_Snippets_Misc/astoria northwind client/vb/source.vb#linqqueryclientevalspecific)]

In this example, the expression `(basePrice – (basePrice * discount))` is evaluated on the client. Because of this, the actual query URI `http://localhost:12345/northwind.svc/Products()?$filter=(UnitPrice gt 90.00M) and substringof('bike',ProductName)` that is sent to the data service contains the already calculated decimal value of `90` in the filter clause. The other parts of the filtering expression, including the substring expression, are evaluated by the data service. Expressions that are evaluated on the client follow common language runtime (CLR) semantics, while expressions sent to the data service rely on the data service implementation of the [!INCLUDE[ssODataShort](../../../../includes/ssodatashort-md.md)] Protocol. You should also be aware of scenarios where this separate evaluation may cause unexpected results, such as when both the client and service perform time-based evaluations in different time zones.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,24 @@ By default, the client library does not supply credentials when sending a reques
## Example
The following example is from the code-behind page for an Extensible Application Markup Language (XAML) file that is the main page of the Windows Presentation Framework application. This example displays a `LoginWindow` instance to collect authentication credentials from the user, and then uses these credentials when making a request to the data service.

<!-- TODO: review snippet reference [!CODE [Astoria NorthwindClient#ClientCredentials](Astoria NorthwindClient#ClientCredentials)] -->
[!code-csharp[Astoria Northwind Client#ClientCredentials](../../../../samples/snippets/csharp/VS_Snippets_Misc/astoria northwind client/cs/clientcredentials.xaml.cs#clientcredentials)]
[!code-vb[Astoria Northwind Client#ClientCredentials](../../../../samples/snippets/visualbasic/VS_Snippets_Misc/astoria northwind client/vb/clientcredentials.xaml.vb#clientcredentials)]

## Example
The following XAML defines the main page of the WPF application.

<!-- TODO: review snippet reference [!CODE [Astoria NorthwindClient#ClientCredentialsXaml](Astoria NorthwindClient#ClientCredentialsXaml)] -->
[!code-xml[Astoria Northwind Client#ClientCredentialsXaml](../../../../samples/snippets/csharp/VS_Snippets_Misc/astoria northwind client/cs/clientcredentials.xaml#clientcredentialsxaml)]

## Example
The following example is from the code-behind page for the window that is used to collect the authentication credentials from the user before making a request to the data service.

<!-- TODO: review snippet reference [!CODE [Astoria NorthwindClient#ClientCredentialsLogin](Astoria NorthwindClient#ClientCredentialsLogin)] -->
[!code-csharp[Astoria Northwind Client#ClientCredentialsLogin](../../../../samples/snippets/csharp/VS_Snippets_Misc/astoria northwind client/cs/clientcredentialslogin.xaml.cs#clientcredentialslogin)]
[!code-vb[Astoria Northwind Client#ClientCredentialsLogin](../../../../samples/snippets/visualbasic/VS_Snippets_Misc/astoria northwind client/vb/clientcredentialslogin.xaml.vb#clientcredentialslogin)]

## Example
The following XAML defines the login of the WPF application.

<!-- TODO: review snippet reference [!CODE [Astoria NorthwindClient#ClientCredentialsLoginXaml](Astoria NorthwindClient#ClientCredentialsLoginXaml)] -->
[!code-xml[Astoria Northwind Client#ClientCredentialsLoginXaml](../../../../samples/snippets/csharp/VS_Snippets_Misc/astoria northwind client/cs/clientcredentialslogin.xaml#clientcredentialsloginxaml)]

## .NET Framework Security
The following security considerations apply to the example in this topic:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ To configure a [!INCLUDE[indigo2](../../../includes/indigo2-md.md)] service endp

### Code
[!code-csharp[C_HowTo-WCFServiceAndASMXClient#0](../../../samples/snippets/csharp/VS_Snippets_CFX/c_howto-wcfserviceandasmxclient/cs/program.cs#0)]
[!code-vb[C_HowTo-WCFServiceAndASMXClient#0](../../../samples/snippets/visualbasic/VS_Snippets_CFX/c_howto-wcfserviceandasmxclient/vb/program.vb#0)]
[!code-xml[C_HowTo-WCFServiceAndASMXClient#1](../../../samples/snippets/common/VS_Snippets_CFX/c_howto-wcfserviceandasmxclient/common/app.config#1)]
[!code-vb[C_HowTo-WCFServiceAndASMXClient#0](../../../samples/snippets/visualbasic/VS_Snippets_CFX/c_howto-wcfserviceandasmxclient/vb/program.vb#0)]
[!code-xml[C_HowTo-WCFServiceAndASMXClient#1](../../../samples/snippets/csharp/VS_Snippets_CFX/c_howto-wcfserviceandasmxclient/common/app.config#1)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say as we start changing the references from common to csharp that we also pull the snippet out at the same time and also make sure no other topic is referencing that file.


## See Also
[Interoperability with ASP.NET Web Services](../../../docs/framework/wcf/feature-details/interop-with-aspnet-web-services.md)
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Policy assertions describe the capabilities and requirements of a service endpoi

1. Add the importer type to the `<extensions>` element inside the [\<policyImporters>](../../../../docs/framework/configure-apps/file-schema/wcf/policyimporters.md) element in the client configuration file.

<!-- TODO: review snippet reference [!code[CustomPolicySample#7(../../../../samples/snippets/common/VS_Snippets_CFX/custompolicysample/common/client.exe.config#7)] -->
[!code-xml[CustomPolicySample#7](../../../../samples/snippets/csharp/VS_Snippets_CFX/custompolicysample/cs/client.exe.config#7)]

2. In the client application, use the <xref:System.ServiceModel.Description.MetadataResolver?displayProperty=fullName> or <xref:System.ServiceModel.Description.WsdlImporter?displayProperty=fullName> to resolve the metadata and the importer is invoked automatically.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You can inspect or modify the incoming or outgoing messages across a [!INCLUDE[i
[!code-csharp[Interceptors#8](../../../../samples/snippets/csharp/VS_Snippets_CFX/interceptors/cs/insertingbehaviors.cs#8)]
[!code-vb[Interceptors#8](../../../../samples/snippets/visualbasic/VS_Snippets_CFX/interceptors/vb/insertingbehaviors.vb#8)]

<!-- TODO: review snippet reference [!code[Interceptors#9](../../../../samples/snippets/common/VS_Snippets_CFX/interceptors/common/hostapplication.exe.config#9)] -->
[!code-xml[Interceptors#9](../../../../samples/snippets/csharp/VS_Snippets_CFX/interceptors/cs/hostapplication.exe.config#9)]

## See Also
<xref:System.ServiceModel.Dispatcher.IClientMessageInspector?displayProperty=fullName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You can inspect or modify the incoming or outgoing messages for a single operati
[!code-csharp[Interceptors#5](../../../../samples/snippets/csharp/VS_Snippets_CFX/interceptors/cs/insertingbehaviors.cs#5)]
[!code-vb[Interceptors#5](../../../../samples/snippets/visualbasic/VS_Snippets_CFX/interceptors/vb/insertingbehaviors.vb#5)]

<!-- TODO: review snippet reference [!code[Interceptors#3](../../../../samples/snippets/common/VS_Snippets_CFX/interceptors/common/client.exe.config#3)] -->
[!code-xml[Interceptors#3](../../../../samples/snippets/csharp/VS_Snippets_CFX/interceptors/cs/client.exe.config#3)]

## See Also
[Configuring and Extending the Runtime with Behaviors](../../../../docs/framework/wcf/extending/configuring-and-extending-the-runtime-with-behaviors.md)
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ To configure a [!INCLUDE[indigo1](../../../../includes/indigo1-md.md)] service e

[!code-csharp[C_HowTo-WCFServiceAndASMXClient#0](../../../../samples/snippets/csharp/VS_Snippets_CFX/c_howto-wcfserviceandasmxclient/cs/program.cs#0)]
[!code-vb[C_HowTo-WCFServiceAndASMXClient#0](../../../../samples/snippets/visualbasic/VS_Snippets_CFX/c_howto-wcfserviceandasmxclient/vb/program.vb#0)]
<!-- TODO: review snippet reference [!code[C_HowTo-WCFServiceAndASMXClient#1](../../../../samples/snippets/common/VS_Snippets_CFX/c_howto-wcfserviceandasmxclient/common/app.config#1)] -->
[!code-xml[C_HowTo-WCFServiceAndASMXClient#1](../../../../samples/snippets/csharp/VS_Snippets_CFX/c_howto-wcfserviceandasmxclient/common/app.config#1)]

## See Also
[How to: Create a Service Endpoint in Code](../../../../docs/framework/wcf/feature-details/how-to-create-a-service-endpoint-in-code.md)
Expand Down
Loading