Skip to content

Commit

Permalink
Merge pull request #5 from dotnet/master
Browse files Browse the repository at this point in the history
Update from dotnet/SqlClient
  • Loading branch information
karinazhou committed Oct 3, 2019
2 parents 4a2e322 + 0ae4f71 commit 06f29a3
Show file tree
Hide file tree
Showing 442 changed files with 33,824 additions and 2,208 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ bld/
# Visual Studio 2017 auto generated files
Generated\ Files/

# Visual Studio Code settings
.vscode/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
Expand Down Expand Up @@ -351,3 +354,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# Nuget package files
.nuget/
12 changes: 9 additions & 3 deletions BUILDGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Once the environment is setup properly, execute the desired set of commands belo
```bash
> msbuild /t:restore
# Restores Nuget Packages.
```
```

```bash
> msbuild /t:BuildAllConfigurations
Expand Down Expand Up @@ -79,11 +79,11 @@ Windows (`netcoreapp2.1`):
```bash
> dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.SqlClient.Tests.csproj" /p:Platform="AnyCPU" /p:Configuration="Release" /p:TestTargetOS="Windowsnetcoreapp" --no-build -v n --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests"
```

Windows (`net46 x86`):
```bash
> dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.SqlClient.Tests.csproj" /p:Platform="Win32" /p:Configuration="Release" /p:TestTargetOS="Windowsnetfx" --no-build -v n --filter "category!=nonnetfxtests&category!=failing&category!=nonwindowstests"
```
```

Windows (`net46 x64`):
```bash
Expand Down Expand Up @@ -134,3 +134,9 @@ Unix (`netcoreapp2.1`):
```bash
> dotnet test "src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" /p:Platform="AnyCPU" /p:Configuration="Release" /p:TestTargetOS="Unixnetcoreapp" --no-build -v n --filter "category!=nonnetcoreapptests&category!=failing&category!=nonlinuxtests&category!=nonuaptests"
```

## Run A Single Test
```bash
> dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" /p:Platform="AnyCPU" /p:Configuration="Debug" /p:TestTargetOS="Windowsnetcoreapp" --no-build -v n --filter "FullyQualifiedName=Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted.CspProviderExt.TestKeysFromCertificatesCreatedWithMultipleCryptoProviders"
```

22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Preview Release 1.1.0-preview1.19275.1] - 2019-10-02

### Added
- Added SqlFileStream support for .NET Framework with `Microsoft.Data.SqlTypes.SqlFileStream` class introduced. [#210](https://github.com/dotnet/SqlClient/pull/210)
- Added support for Visual Studio Intellisense with XML Documentation. [#210](https://github.com/dotnet/SqlClient/pull/210)

### Changes
- Synchronized ref definitions with driver classes. [#180](https://github.com/dotnet/SqlClient/pull/180)
- Updated `SNINativeMethodWrapper` to provide the underlying error in the inner exception when we fail to load SNI.dll. [#225](https://github.com/dotnet/SqlClient/pull/225)
- Added .editorconfig file and set formatting rules. [#193](https://github.com/dotnet/SqlClient/pull/193)
- Changes done to handle statistics well and to cleanup `AutoResetEvent` on disconnect. [#232](https://github.com/dotnet/SqlClient/pull/232)


## [Hotfix & Stable Release 1.0.19269.1] - 2019-09-26

### Fixed Issues
- `SqlCommand.StatementCompleted` event never being fired [#212](https://github.com/dotnet/SqlClient/issues/212)
- Added missing `Authentication` property to `SqlConnectionStringBuilder` reference assembly
- Reverted API changes in `SqlAuthenticationParameters` which had changed the `public string Resource` property to `public string[] Scopes`

## [Hotfix & Stable Release 1.0.19249.1] - 2019-09-06

### Fixed Issues
- Fixed issues with large data reading in Unix applications when data is spanned over multiple packets. [#171](https://github.com/dotnet/SqlClient/pull/171)

Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@

# Microsoft SqlClient Data Provider for SQL Server

Welcome to the home of Microsoft ADO.NET driver for SQL Server aka Microsoft.Data.SqlClient GitHub repository.
Welcome to the home of Microsoft ADO.NET driver for SQL Server aka the Microsoft.Data.SqlClient GitHub repository.

Microsoft.Data.SqlClient is a data provider for Microsoft Sql Server. Now in General Availability, it is a union of the two System.Data.SqlClient components which live independently in .NET Framework and .NET Core. Going forward, support for new SQL Server features will be implemented in Microsoft.Data.SqlClient.

## Supportability
The Microsoft.Data.SqlClient package supports below environments:

The Microsoft.Data.SqlClient package supports the below environments:

- .NET Framework 4.6+
- .NET Core 2.1+
- .NET Standard 2.0+.

The source code of this library is now available under MIT license.
The source code of this library is now available under the MIT license.

## Download

Expand Down
2 changes: 1 addition & 1 deletion build.proj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="BuildAll" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="15.0" DefaultTargets="BuildAllConfigurations" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="src/Directory.Build.props" />
<Import Project="$(ToolsDir)targets\GenerateNugetPackage.targets" />

Expand Down
86 changes: 86 additions & 0 deletions doc/samples/DataColumn_DataType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System;
using System.Data;
// <Snippet1>
using Microsoft.Data.SqlClient;
using System.Data.SqlTypes;

class Program
{
static void Main()
{
string connectionString = GetConnectionString();
GetSqlTypesAW(connectionString);
Console.ReadLine();
}
static private void GetSqlTypesAW(string connectionString)
{
// Create a DataTable and specify a SqlType
// for each column.
DataTable table = new DataTable();
DataColumn icolumnolumn =
table.Columns.Add("SalesOrderID", typeof(SqlInt32));
DataColumn priceColumn =
table.Columns.Add("UnitPrice", typeof(SqlMoney));
DataColumn totalColumn =
table.Columns.Add("LineTotal", typeof(SqlDecimal));
DataColumn columnModifiedDate =
table.Columns.Add("ModifiedDate", typeof(SqlDateTime));

// Open a connection to SQL Server and fill the DataTable
// with data from the Sales.SalesOrderDetail table
// in the AdventureWorks sample database.
using (SqlConnection connection = new SqlConnection(connectionString))
{
string queryString =
"SELECT TOP 5 SalesOrderID, UnitPrice, LineTotal, ModifiedDate "
+ "FROM Sales.SalesOrderDetail WHERE LineTotal < @LineTotal";

// Create the SqlCommand.
SqlCommand command = new SqlCommand(queryString, connection);

// Create the SqlParameter and assign a value.
SqlParameter parameter =
new SqlParameter("@LineTotal", SqlDbType.Decimal);
parameter.Value = 1.5;
command.Parameters.Add(parameter);

// Open the connection and load the data.
connection.Open();
SqlDataReader reader =
command.ExecuteReader(CommandBehavior.CloseConnection);
table.Load(reader);

// Close the SqlDataReader.
reader.Close();
}

// Display the SqlType of each column.
Console.WriteLine("Data Types:");
foreach (DataColumn column in table.Columns)
{
Console.WriteLine(" {0} -- {1}",
column.ColumnName, column.DataType.UnderlyingSystemType);
}

// Display the value for each row.
Console.WriteLine("Values:");
foreach (DataRow row in table.Rows)
{
Console.Write(" {0}, ", row["SalesOrderID"]);
Console.Write(" {0}, ", row["UnitPrice"]);
Console.Write(" {0}, ", row["LineTotal"]);
Console.Write(" {0} ", row["ModifiedDate"]);
Console.WriteLine();
}
}

static private string GetConnectionString()
{
// To avoid storing the connection string in your code,
// you can retrieve it from a configuration file, using the
// System.Configuration.ConfigurationSettings.AppSettings property
return "Data Source=(local);Initial Catalog=AdventureWorks;"
+ "Integrated Security=SSPI;";
}
}
// </Snippet1>
72 changes: 72 additions & 0 deletions doc/samples/DataTableReader_GetValues.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// <Snippet1>
using System;
using System.Data;
using Microsoft.Data.SqlClient;

class Program
{
// using Microsoft.Data.SqlClient;
private static void TestGetValues(DataTableReader reader)
{
// Given a DataTableReader, use the GetValues
// method to retrieve a full row of data.
// Test the GetValues method, passing in an array large
// enough for all the columns.
Object[] values = new Object[reader.FieldCount];
int fieldCount = reader.GetValues(values);

Console.WriteLine("reader.GetValues retrieved {0} columns.",
fieldCount);
for (int i = 0; i < fieldCount; i++)
Console.WriteLine(values[i]);

Console.WriteLine();

// Now repeat, using an array that may contain a different
// number of columns than the original data. This should work correctly,
// whether the size of the array is larger or smaller than
// the number of columns.

// Attempt to retrieve three columns of data.
values = new Object[3];
fieldCount = reader.GetValues(values);
Console.WriteLine("reader.GetValues retrieved {0} columns.",
fieldCount);
for (int i = 0; i < fieldCount; i++)
Console.WriteLine(values[i]);
}
// </Snippet1>

// <Snippet2>
// using Microsoft.Data.SqlClient;
private static void TestGetValues(SqlDataReader reader)
{
// Given a SqlDataReader, use the GetValues
// method to retrieve a full row of data.
// Test the GetValues method, passing in an array large
// enough for all the columns.
Object[] values = new Object[reader.FieldCount];
int fieldCount = reader.GetValues(values);

Console.WriteLine("reader.GetValues retrieved {0} columns.",
fieldCount);
for (int i = 0; i < fieldCount; i++)
Console.WriteLine(values[i]);

Console.WriteLine();

// Now repeat, using an array that may contain a different
// number of columns than the original data. This should work correctly,
// whether the size of the array is larger or smaller than
// the number of columns.

// Attempt to retrieve three columns of data.
values = new Object[3];
fieldCount = reader.GetValues(values);
Console.WriteLine("reader.GetValues retrieved {0} columns.",
fieldCount);
for (int i = 0; i < fieldCount; i++)
Console.WriteLine(values[i]);
}
// </Snippet2>
}
109 changes: 109 additions & 0 deletions doc/samples/IBinarySerialize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System;
using System.IO;
using System.Data;
using System.Data.SqlTypes;
using Microsoft.Data.SqlClient.Server;
using System.Text;

namespace test
{

public class Class1 : IBinarySerialize
{

[STAThread]
static void Main(string[] args)
{
string fileName = "info.dat";
Class1 temp = new Class1();

FileStream fs = new FileStream(fileName, FileMode.Create);
BinaryWriter w = new BinaryWriter(fs);

temp.Write(w);

w.Close();
fs.Close();

fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);

temp.Read(r);

Console.WriteLine("String value: " + temp.StringValue);
Console.WriteLine("Double value: " + temp.DoubleValue);

r.Close();
fs.Close();
}

public string StringValue;
public double DoubleValue;

//<Snippet1>
// The binary layout is as follows:
// Bytes 0 - 19: string text, padded to the right with null characters
// Bytes 20+: Double value

// using Microsoft.Data.SqlClient.Server;
public void Read(System.IO.BinaryReader r)
{

int maxStringSize = 20;
char[] chars;
int stringEnd;
string stringValue;
double doubleValue;

// Read the characters from the binary stream.
chars = r.ReadChars(maxStringSize);

// Find the start of the null character padding.
stringEnd = Array.IndexOf(chars, '\0');

if (stringEnd == 0)
{
stringValue = null;
return;
}

// Build the string from the array of characters.
stringValue = new String(chars, 0, stringEnd);

// Read the double value from the binary stream.
doubleValue = r.ReadDouble();

// Set the object's properties equal to the values.
this.StringValue = stringValue;
this.DoubleValue = doubleValue;
}
//</Snippet1>

//<Snippet2>
// The binary layout is as follows:
// Bytes 0 - 19: string text, padded to the right with null characters
// Bytes 20+: Double value

// using Microsoft.Data.SqlClient.Server;
public void Write(System.IO.BinaryWriter w)
{
int maxStringSize = 20;
string stringValue = "The value of PI: ";
string paddedString;
double value = 3.14159;

// Pad the string from the right with null characters.
paddedString = stringValue.PadRight(maxStringSize, '\0');

// Write the string value one byte at a time.
for (int i = 0; i < paddedString.Length; i++)
{
w.Write(paddedString[i]);
}

// Write the double value.
w.Write(value);
}
//</Snippet2>
}
}
Loading

0 comments on commit 06f29a3

Please sign in to comment.