-
Notifications
You must be signed in to change notification settings - Fork 314
Feature | Add SqlDataSourceEnumerator #1430
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
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
dcd629b
Added UDP Broadcast to SSRP
Kaur-Parminder 742107c
Added SqlDataSourceEnumerator Public API and AppContext for Helpers (…
Kaur-Parminder 8374240
Added AppContext change to unit test
Kaur-Parminder d629a1c
Increased recieve buffer size to match to native recieve buffer size …
Kaur-Parminder 0bc15f8
reset to d629a1c
Kaur-Parminder 68ae3ba
Merge remote-tracking branch 'Upstream/main' into MSDEnumerator
Kaur-Parminder e2cca89
Added stopwatch to track time elapsed for max timeouts in recieve dat…
Kaur-Parminder f47181a
license
Kaur-Parminder ec6e623
exclude appcontext test
Kaur-Parminder a611863
Comments and url references
Kaur-Parminder a4d9de6
review comment
Kaur-Parminder 968183b
fix strbuilder overwrite
Kaur-Parminder efa3d74
VS Suggestions
Kaur-Parminder 5bb8130
EventSource Trace
Kaur-Parminder 8315240
Documentation and ref
Kaur-Parminder 62d67d9
moved sni native wrapper methods from windows to common
Kaur-Parminder d126085
reverting back test nuget version
Kaur-Parminder d1a95ed
Apply suggestions from code review
Kaur-Parminder b4b0d75
removing body expression from SNIServerEnumClose
Kaur-Parminder 2255f1a
body expression for GetTimeoutSeconds
Kaur-Parminder ce39cd7
created util for sqldatasourceenumerator
Kaur-Parminder 67f0bbf
more utils
Kaur-Parminder 3f9ad32
license for util file
Kaur-Parminder d93127c
fix (#2)
DavoudEshtehari 58f8f15
merge
Kaur-Parminder 4ae25f2
changing back encoding to ASCII for SRRP except UDPbroadcast menthod
Kaur-Parminder 3927340
Noimplementation exception for Managed SNI and test update for same
Kaur-Parminder 7aebf45
SNI Update
Kaur-Parminder e7931b5
Revert "SNI Update"
Kaur-Parminder 855f69f
Merge branch 'dotnet:main' into main
Kaur-Parminder 81e26f6
Merge branch 'main' into MSDEnumerator
Kaur-Parminder 7ff8220
Fix | SqlDSEnumerator net core (#3)
DavoudEshtehari 54b3c36
added test dependcy for ServiceController.dll
Kaur-Parminder f09becc
review comments
Kaur-Parminder c0f6bad
Fix build issue
DavoudEshtehari 36d6ade
use TargetsWindows
DavoudEshtehari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
//<Snippet1> | ||
using Microsoft.Data.Sql; | ||
|
||
class Program | ||
{ | ||
static void Main() | ||
{ | ||
// Retrieve the enumerator instance and then the data. | ||
SqlDataSourceEnumerator instance = | ||
SqlDataSourceEnumerator.Instance; | ||
System.Data.DataTable table = instance.GetDataSources(); | ||
|
||
// Display the contents of the table. | ||
DisplayData(table); | ||
|
||
Console.WriteLine("Press any key to continue."); | ||
Console.ReadKey(); | ||
} | ||
|
||
private static void DisplayData(System.Data.DataTable table) | ||
{ | ||
foreach (System.Data.DataRow row in table.Rows) | ||
{ | ||
foreach (System.Data.DataColumn col in table.Columns) | ||
{ | ||
Console.WriteLine("{0} = {1}", col.ColumnName, row[col]); | ||
} | ||
Console.WriteLine("============================"); | ||
} | ||
} | ||
} | ||
//</Snippet1> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
//<Snippet1> | ||
using Microsoft.Data.Sql; | ||
|
||
class Program | ||
{ | ||
static void Main() | ||
{ | ||
// Retrieve the enumerator instance, and | ||
// then retrieve the data sources. | ||
SqlDataSourceEnumerator instance = | ||
SqlDataSourceEnumerator.Instance; | ||
System.Data.DataTable table = instance.GetDataSources(); | ||
|
||
// Filter the sources to just show SQL Server 2012 instances. | ||
System.Data.DataRow[] rows = table.Select("Version LIKE '11%'"); | ||
foreach (System.Data.DataRow row in rows) | ||
{ | ||
Console.WriteLine(row["ServerName"]); | ||
} | ||
Console.WriteLine("Press any key to continue."); | ||
Console.ReadKey(); | ||
} | ||
} | ||
//</Snippet1> |
65 changes: 65 additions & 0 deletions
65
doc/snippets/Microsoft.Data.Sql/SqlDataSourceEnumerator.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0"?> | ||
<docs> | ||
<members name="SqlDataSourceEnumerator"> | ||
<SqlDataSourceEnumerator> | ||
<summary>Provides a mechanism for enumerating all available instances of SQL Server within the local network.</summary> | ||
<remarks> | ||
<format type="text/markdown"><![CDATA[ | ||
|
||
## Remarks | ||
SQL Server makes it possible for applications to determine the existence of its instances within the current network. The <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator> class exposes this information to the application developer, providing a <xref:System.Data.DataTable> containing information about all the available servers. This returned table contains a list of server instances that matches the list provided when a user attempts to create a new connection, and on the `Connection Properties` dialog box, expands the drop-down list containing all the available servers. | ||
|
||
]]></format> | ||
</remarks> | ||
<related type="Article" href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">Enumerating Instances of SQL Server</related> | ||
</SqlDataSourceEnumerator> | ||
<GetDataSources> | ||
<summary>Retrieves a <see cref="T:System.Data.DataTable" /> containing information about all visible SQL Server instances.</summary> | ||
<returns>A <see cref="T:System.Data.DataTable" /> containing information about the visible SQL Server instances.</returns> | ||
<remarks> | ||
<format type="text/markdown"><![CDATA[ | ||
|
||
## Remarks | ||
The table returned by this method contains the following columns, all of which contain strings: | ||
|
||
|Column|Description| | ||
|------------|-----------------| | ||
|**ServerName**|Name of the server.| | ||
|**InstanceName**|Name of the server instance. Blank if the server is running as the default instance.| | ||
|**IsClustered**|Indicates whether the server is part of a cluster.| | ||
|**Version**|Version of the server:<br /><br />10.0.xx for SQL Server 2008<br />10.50.x for SQL Server 2008 R2<br />11.0.xx for SQL Server 2012<br />12.0.xx for SQL Server 2014<br />13.0.xx for SQL Server 2016<br />14.0.xx for SQL Server 2017| | ||
|
||
> [!NOTE] | ||
> Due to the nature of the mechanism used by <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator> to locate data sources on a network, the method will not always return a complete list of the available servers, and the list might not be the same on every call. If you plan to use this function to let users select a server from a list, make sure that you always also supply an option to type in a name that is not in the list, in case the server enumeration does not return all the available servers. In addition, this method may take a significant amount of time to execute, so be careful about calling it when performance is critical. | ||
|
||
## Examples | ||
The following console application retrieves information about all the visible SQL Server instances and displays the information in the console window. | ||
|
||
[!code-csharp[SqlDataSourceEnumerator.Example#1](~/../sqlclient/doc/samples/SqlDataSourceEnumeratorExample.cs#1)] | ||
|
||
]]></format> | ||
</remarks> | ||
<related type="Article" href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">Enumerating Instances of SQL Server</related> | ||
</GetDataSources> | ||
<Instance> | ||
<summary>Gets an instance of the <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator"/>, which can be used to retrieve information about available SQL Server instances.</summary> | ||
<value>An instance of the <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator"/> used to retrieve information about available SQL Server instances.</value> | ||
<remarks> | ||
<format type="text/markdown"><] | ||
|
||
## Examples | ||
The following console application displays a list of all the available SQL Server 2005 instances within the local network. This code uses the <xref:System.Data.DataTable.Select%2A> method to filter the rows in the table returned by the <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator.GetDataSources%2A> method. | ||
[!code-csharp[SqlDataSourceEnumeratorVersionExample#1](~/../sqlclient/doc/samples/SqlDataSourceEnumeratorVersionExample.cs#1)] | ||
|
||
]]></format> | ||
</remarks> | ||
<related type="Article" href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">Enumerating Instances of SQL Server</related> | ||
|
||
</Instance> | ||
</members> | ||
</docs> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Sql/SqlDataSourceEnumerator.Unix.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
using System.Data; | ||
using System.Data.Common; | ||
using Microsoft.Data.SqlClient.Server; | ||
|
||
namespace Microsoft.Data.Sql | ||
{ | ||
/// <include file='../../../../doc/snippets/Microsoft.Data.Sql/SqlDataSourceEnumerator.xml' path='docs/members[@name="SqlDataSourceEnumerator"]/SqlDataSourceEnumerator/*' /> | ||
public sealed partial class SqlDataSourceEnumerator : DbDataSourceEnumerator | ||
{ | ||
private partial DataTable GetDataSourcesInternal() => SqlDataSourceEnumeratorManagedHelper.GetDataSources(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.