๐ OData Connected Service 0.7.1 Release
๐ก Newskategorie: Programmierung
๐ Quelle: devblogs.microsoft.com
We are pleased to announce a new release of OData Connected Service, version 0.7.1. This version adds the following important features and bug fixes:
- VB.NET support
- Option to include or exclude operation imports from generated code
- Ability to access the metadata endpoint behind a proxy
- Bug fixes and other improvements
You can get the extension from the Visual Studio Marketplace.
1. VB.NET Support
You can now use OData Connected Service extension to generate OData client code for Visual Basic projects. The features supported in C# are also supported in VB.NET projects.
Letโs create a simple VB.NET project to demonstrate how it works. Open Visual Studio and create a VB .NET Core Console App.
When the new project is ready, right-click the project node from the Solution Explorer and then choose Add > Connected Service in the context menu that appears
In the Connected Services tab, select OData Connected Service.
This loads the OData Connected Service configuration wizard. For this demo, weโll keep things simple and stick to the default settings. For the service address, use the sample Trip Pin service endpoint: https://services.odata.org/v4/TripPinService
Click Finish to start the client code generation process. After the process is complete, a Connected Services node is added to your project together with a child node named โOData Serviceโ. Inside the folder you should see the generated Reference.vb file.
Weโll use the generated code to fetch a list of people from the service and display their names in the console.
Open the Program.vb file and replace its content with the following code:
Imports System ' this is the namespace that contains the generated code, based on the namespace defined in the service metadata Imports OcsVbDemo.Microsoft.OData.SampleService.Models.TripPin Module Program Sub Main(args As String()) DisplayPeople().Wait() End Sub ''' <summary> ''' Fetches and displayes a list of people from the OData service ''' </summary> ''' <returns></returns> Async Function DisplayPeople() As Task Dim container = New DefaultContainer(New Uri("https://services.odata.org/v4/TripPinService")) Dim people = Await container.People.ExecuteAsync() For Each person In people Console.WriteLine(person.FirstName) Next End Function End Module
ย
The DefaultContainer
is a generated class that inherits from DataServiceContext and gives us access to the resources exposed by the service. We create a Container instance using the URL of the service root. The container has a generated People property which weโll use to execute a query against the People entity set on the OData service and then display the results.
Finally, letโs run the app. You should see a list of names displayed on the console:
2. Include/Exclude operation imports
This feature allows you to select the operations you want included in the generated code and exclude the ones you donโt want. This gives you more control and helps keep the generated code lean. There is more work being done in this area, and in an upcoming release, you will also have the option to exclude entity types that you donโt need.
This feature is available on the new Function/Action Imports page of the wizard.
In the example above, GetNearestAirport and ResetDataSource will be generated, but GetPersonWithMostFriends will not.
Here are some important things to keep in mind regarding this feature:
- It only covers operation imports (action and function imports), which are exposed directly on the entity container, it does not affect functions and actions accessible through entity types.
- When an operation import is excluded, all its overloads get excluded
- It is not supported for OData v3 services or lower.
3. Fetching service metadata behind a web proxy
Previously, when you used the connected service on a network that has a web proxy, the call to fetch service metadata would fail. To address this issue, we have provided a means for you to specify the web proxy configuration and credentials needed to access the network in such situations. These settings are not saved in the generated client, they are only used to fetch the metadata document during code generation. They are also not persisted or cached by default, meaning you would have to enter them each time you add or update a connected service.
You can specify the web proxy settings on the first page of the configuration wizard:
4. Bug fixes and minor improvements
- A bug was reported in the previous release that caused the connected service to fail if you provided a local file as the service address. This bug has been fixed
- We added a Browser button to make it easier to select local files
Stay tuned for the next release.
Special thanks to the following contributors:
- Chebotov Nickolay โ VB support feature.
The post OData Connected Service 0.7.1 Release appeared first on OData.
...