../../../../Common
true
false
true
true
true
true
true
true
true
true
true
C# Example.ExtendedProvider
C# Extended DDEX Provider Sample
Demonstrates how to implement a scenario-complete DDEX provider.
This sample demonstrates how to implement a DDEX provider based on the
.NET Framework Data Provider for SQL Server that supports all the common
data design time scenarios.
Supplying all features of the basic DDEX provider sample
Embedding the XML support files as assembly resources
Customizing the data object selector service
Customizing the data object identifier resolver service
Customizing the data source information service
Enabling localization of many exposed strings
Supporting all the common data design time scenarios
New
Example
1
Data
C#
VisualStudioIntegration\Samples\Data\CSharp\Example.ExtendedProvider\
ExtendedProvider.sln
VisualStudioIntegration\Samples\Data\CSharp\Example.ExtendedProvider\UnitTests
ExtendedProvider.UnitTests.csproj
Data
DDEX
Provider
This sample focuses on fixing the issues surrounding the data design time
scenarios that were in the basic DDEX provider sample. This is done by
providing an assembly containing code that customizes key parts of the
provider.
The main addition in this sample is a custom data object selector to
supplement or in some cases replace the schema information returned by
the .NET Framework Data Provider for SQL Server. This includes providing
information such as the server instance name, the default schema, as well
as collections like indexes and index columns (which include primary
and unique keys), foreign keys and foreign key columns, stored procedures
and stored procedure parameters and columns, and user-defined functions
and user-defined function parameters and columns.
A further addition is a custom object identifier resolver, which
correctly expands an identifier based on the active connection. For
example, if the identifier "Customers" is supplied, the active connection
can expand this to "Northwind.dbo.Customers" based on the current active
database and default schema in that database.
Other enhancements include a customized data source information class
to return properties that require computing and the localization of
some strings.
Due to the extensions added in this sample, this provider will only
connect to instances of Microsoft SQL Server 2005 or later. Also note
that table-valued functions with parameters are not supported in some
data design scenarios due to a lack of extensibility in this area.
Since there is already a DDEX provider based on the .NET Framework Data
Provider for SQL Server that ships with Visual Studio, installing another
such provider has potential for ambiguity, as many data design scenarios
refer to the ADO.NET provider invariant name only and from this there is
a one-to-many mapping to DDEX providers. To ensure that this sample DDEX
provider is being used for the various data design scenarios, make sure
the last selected data source and provider combination in the data
connection dialog uses this sample DDEX provider. Visual Studio
incorporates a heuristic for determining the correct DDEX provider to use
given an ADO.NET invariant name that is based on the last provider
selection made for each registered DDEX data source.
Open the ExtendedProvider.sln solution.
Press F5 to build the sample and register it in the experimental instance,
then launch Visual Studio from the experimental instance.
Alternatively, run the Install.cmd /ranu script from a
command line, passing in a Visual Studio registry root (optional) and
location of the built assembly binary (required). The Visual Studio
registry root defaults to the SDK experimental instance. Exclude the
/ranu argument when installing to a non-experimental Visual
Studio registry hive.
To add a data connection...
On the View menu, click Server Explorer.
In the Server Explorer window, right click the Data
Connections node and choose Add Connection....
If the Add Connection dialog shows, click the
Change... button to show the Change Data Source
dialog.
Pick the Microsoft SQL Server data source and drop down
the Data Provider combo box, then choose this sample's
data provider (marked as "Extended Sample").
Click OK to move to the Add Connection
dialog.
In the property grid, enter information to connect to an instance of
Microsoft SQL Server. For the SQL Express instance installed by
default with Visual Studio, enter ".\SQLEXPRESS" as the Data
Source value.
Click OK to create a connection in the Server Explorer.
To enumerate data objects...
Follow the steps for adding a data connection with this provider.
Expand the resulting data connection.
Expand the various nodes to see data objects.
To initiate an end-to-end data design time scenario
Create a new VB or C# project.
On the Data menu, click Show Data Sources.
In the Data Sources window, click Add New Data
Source....
Follow the steps in the Data Source Configuration Wizard.
Visual Studio SDK Website
http://msdn.microsoft.com/vstudio/extend
SqlObjectIdentifierResolverTests.ExpandIdentifierTest. Ensure an
identifier "Customers" is properly expanded to "Northwind", "dbo",
"Customers" given appropriate mocks that return a hard coded default
catalog and schema.
SqlObjectSelectorTests.SelectObjectsTest. Ensure all the different
enumerations execute successfully and in some cases, check the actual
returned result set.
SqlSourceInformationTests.ItemIndexerTest. Ensure retrieval of the
default schema executes successfully and returns the correct value.
See the DDEX SDK documentation for information about functional tests.
ExtendedProvider.reg
This file contains the registry entries that register this provider.
SqlObjectIdentifierResolver.cs
This file contains the custom implementation of the data object
identifier resolver connection service.
SqlObjectSelector.cs
This file contains the custom implementation of the data object
selector connection service.
SqlObjectSupport.xml
This file defines the structure of the data source as a set of objects.
SqlObjectTypes.cs
This file contains static strings identifying the different types of
objects defined in the data object support XML file, for programmatic
purposes.
SqlSourceInformation.cs
This file contains the custom implementation of the data source
information connection service.
SqlViewSupport.xml
This file defines the presentation of the data source objects in a
hierarchical form.
2007-07-08
Created this sample for the Visual Studio 2008 SDK.