Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -2,7 +2,7 @@
using System;
using Microsoft.Data.SqlClient;

namespace CustomAppIdAuthProviderExample
namespace ApplicationClientIdAzureAuthenticationProvider
{
public class Program
{
Expand Down
2 changes: 1 addition & 1 deletion doc/samples/AzureKeyVaultProviderExample_2_0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.Data.SqlClient;
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;

namespace Microsoft.Data.SqlClient.Samples
namespace AzureKeyVaultProviderExample_2_0
{
public class AzureKeyVaultProviderExample_2_0
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
/*
Comment thread
ErikEJ marked this conversation as resolved.
Outdated
using System;
//<Snippet1>
using System.Collections.Generic;
using System.Security.Cryptography;
Expand All @@ -7,7 +8,7 @@
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;
using Microsoft.IdentityModel.Clients.ActiveDirectory;

namespace AKVEnclaveExample
namespace AzureKeyVaultProviderWithEnclaveProviderExample
{
class Program
{
Expand Down Expand Up @@ -264,3 +265,4 @@ public CustomerRecord(int id, string fName, string lName)
}
}
//</Snippet1>
*/
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.Data.SqlClient;
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;

namespace AKVEnclaveExample_2_0
namespace AzureKeyVaultProviderWithEnclaveProviderExample_2_0
{
class Program
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.Data.SqlClient;
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;

namespace AzureKeyVaultProviderExample
namespace AzureKeyVaultProvider_ColumnEncryptionKeyCacheScope
{
// <Snippet1>
class Program
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
namespace ConnectionStringSettings_RetrieveFromConfig;

using System;
// <Snippet1>
using System.Configuration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
namespace ConnectionStringSettings_RetrieveFromConfigByName;

using System;
using System.Configuration;

class Program
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
namespace ConnectionStringSettings_RetrieveFromConfigByProvider;

using System;
using System.Data;
using Microsoft.Data.SqlClient;
using System.Configuration;
Expand Down
8 changes: 7 additions & 1 deletion doc/samples/ConnectionStringsWeb_Encrypt.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
/*
Comment thread
ErikEJ marked this conversation as resolved.
#if NETFRAMEWORK
namespace ConnectionStringsWeb_Encrypt;

using System;
using System.Configuration;
using System.Web.Configuration;

Expand Down Expand Up @@ -35,3 +39,5 @@ static void ToggleWebEncrypt()
}
// </Snippet1>
}
#endif
*/
6 changes: 4 additions & 2 deletions doc/samples/ConnectionStrings_Encrypt.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
namespace ConnectionStrings_Encrypt;

using System;
using System.Configuration;

class Program
Expand All @@ -7,7 +9,7 @@ static void Main()
{
}
// <Snippet1>
static void ToggleConfigEncryption(string exeFile)
static void ToggleConfigEncryption(string exeConfigName)
Comment thread
ErikEJ marked this conversation as resolved.
{
// Takes the executable file name without the
// .config extension.
Comment thread
ErikEJ marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.Data.SqlClient;
using Microsoft.Identity.Client;

namespace CustomDeviceCodeFlowAuthProviderExample
namespace CustomDeviceCodeFlowAzureAuthenticationProviderExample
{
/// <summary>
/// Example demonstrating creating a custom device code flow authentication provider and attaching it to the driver.
Expand Down
2 changes: 2 additions & 0 deletions doc/samples/DataColumn_DataType.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
namespace DataColumn_DataType;

using System;
using System.Data;
// <Snippet1>
Expand Down
2 changes: 2 additions & 0 deletions doc/samples/DataTableReader_GetValues.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
namespace DataTableReader_GetValues;

// <Snippet1>
using System;
using System.Data;
Expand Down
2 changes: 1 addition & 1 deletion doc/samples/IBinarySerialize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.SqlServer.Server;
using System.Text;

namespace test
namespace IBinarySerializeCS
{

public class Class1 : IBinarySerialize
Expand Down
4 changes: 4 additions & 0 deletions doc/samples/IDbCommand_CommandTimeout.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#if NETFRAMEWORK
namespace IDbCommand_CommandTimeout;

// <Snippet1>
using System;
using System.Xml;
Expand All @@ -20,3 +23,4 @@ public void CreateSqlCommand()
}
// </Snippet1>
}
#endif
2 changes: 2 additions & 0 deletions doc/samples/Isolation_Snapshot.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
namespace Isolation_Snapshot;

using System;
using System.Data;
// <Snippet1>
Expand Down
2 changes: 2 additions & 0 deletions doc/samples/Isolation_Snapshot1.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
namespace Isolation_Snapshot1;

using System;
using System.Data;
// <Snippet1>
Expand Down
4 changes: 3 additions & 1 deletion doc/samples/Microsoft.Data.SqlClient.Samples.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net462</TargetFrameworks>
Comment thread
ErikEJ marked this conversation as resolved.
<OutputType>Library</OutputType>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand All @@ -16,10 +17,11 @@
<PackageReference Include="Microsoft.Data.SqlClient" />
<PackageReference Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
Comment thread
ErikEJ marked this conversation as resolved.
</ItemGroup>

<!-- .NET Framework references -->
<ItemGroup Condition="$(TargetGroup) == 'netfx'">
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
Comment thread
ErikEJ marked this conversation as resolved.
Comment thread
ErikEJ marked this conversation as resolved.
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" />
<Reference Include="System.Transactions" />
<Reference Include="System.Windows.Forms" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using Microsoft.SqlServer.Server;

namespace test
namespace DataWorks_IBinarySerialize_Sample
Comment thread
ErikEJ marked this conversation as resolved.
{
public class Class1 : IBinarySerialize
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.IO;
namespace DataWorks_SqlFunctionAttribute_Sample;
Comment thread
ErikEJ marked this conversation as resolved.

using System.IO;
using System.Collections;
using Microsoft.SqlServer.Server;

Expand All @@ -20,4 +22,4 @@ public static IEnumerable GetFileDetails(string directoryPath)
}
}
//</Snippet1>
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//<Snippet1>
namespace DataWorks_SqlUserDefinedAggregateAttribute_Sample;

//<Snippet1>
using System;
using System.IO;
using Microsoft.SqlServer.Server;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
namespace DataWorks_SqlUserDefinedTypeAttribute_Sample;

using System;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections;
namespace SqlFunctionAttribute_SqlFunction;

using System.Collections;
//-----------------------------------------------------------------------------
//<Snippet4>
using System.Data.SqlTypes;
Expand Down
2 changes: 2 additions & 0 deletions doc/samples/Microsoft.SqlServer.Server/csharp/SqlMethod.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
namespace SqlMethodCSExample;

using System;
// <Snippet1>
using Microsoft.SqlServer.Server;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//-----------------------------------------------------------------------------
namespace SqlUserDefinedAggregateAttribute_Aggregate1;

//-----------------------------------------------------------------------------
//<Snippet2>
using System;
using System.Data.SqlTypes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//-----------------------------------------------------------------------------
namespace SqlUserDefinedTypeAttribute_Type1;

//-----------------------------------------------------------------------------
//<Snippet5>
using System;
using System.Data.SqlTypes;
Expand Down Expand Up @@ -78,8 +80,8 @@ public static Point Parse(SqlString s)
string[] xy = str.Split(':');

Point pt = new Point();
pt.X = Convert.Toint(xy[0]);
pt.Y = Convert.Toint(xy[1]);
pt.X = Convert.ToInt32(xy[0]);
Comment thread
ErikEJ marked this conversation as resolved.
pt.Y = Convert.ToInt32(xy[1]);
return (pt);
}

Expand Down
27 changes: 24 additions & 3 deletions doc/samples/RegisterCustomKeyStoreProvider_CommandPrecedence.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
// <Snippet1>
namespace RegisterCustomKeyStoreProvider_CommandPrecedence;

using System.Collections.Generic;
using Azure.Identity;
using Microsoft.Data.SqlClient;
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;

// <Snippet1>
class Program
{
static void Main()
static void Main(string connectionString)
Comment thread
ErikEJ marked this conversation as resolved.
{
Dictionary<string, SqlColumnEncryptionKeyStoreProvider> customKeyStoreProviders = new Dictionary<string, SqlColumnEncryptionKeyStoreProvider>();
MyCustomKeyStoreProvider firstProvider = new MyCustomKeyStoreProvider();
Expand All @@ -20,7 +27,7 @@ static void Main()
using (SqlCommand command = connection.CreateCommand())
{
customKeyStoreProviders.Clear();
SqlColumnEncryptionAzureKeyVaultProvider azureKeyVaultProvider = new SqlColumnEncryptionAzureKeyVaultProvider();
SqlColumnEncryptionAzureKeyVaultProvider azureKeyVaultProvider = new SqlColumnEncryptionAzureKeyVaultProvider(new DefaultAzureCredential());
Comment thread
ErikEJ marked this conversation as resolved.
customKeyStoreProviders.Add(SqlColumnEncryptionAzureKeyVaultProvider.ProviderName, azureKeyVaultProvider);
// Registers the provider on the command
// These providers will take precedence over connection-level providers and globally registered providers
Expand All @@ -30,3 +37,17 @@ static void Main()
}
}
// </Snippet1>

class MyCustomKeyStoreProvider : SqlColumnEncryptionKeyStoreProvider
Comment thread
ErikEJ marked this conversation as resolved.
{
public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] encryptedColumnEncryptionKey)
{
// Custom decryption logic here
return new byte[0];
}
public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] columnEncryptionKey)
{
// Custom encryption logic here
return new byte[0];
Comment thread
ErikEJ marked this conversation as resolved.
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
// <Snippet1>
namespace RegisterCustomKeyStoreProvider_ConnectionPrecedence;

using System.Collections.Generic;
using Azure.Core;
using Azure.Identity;
using Microsoft.Data.SqlClient;
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;

// <Snippet1>
class Program
{
static void Main()
static void Main(string connectionString)
Comment thread
ErikEJ marked this conversation as resolved.
{
Dictionary<string, SqlColumnEncryptionKeyStoreProvider> customKeyStoreProviders = new Dictionary<string, SqlColumnEncryptionKeyStoreProvider>();
MyCustomKeyStoreProvider myProvider = new MyCustomKeyStoreProvider();
Expand All @@ -12,7 +20,7 @@ static void Main()
using (SqlConnection connection = new SqlConnection(connectionString))
{
customKeyStoreProviders.Clear();
SqlColumnEncryptionAzureKeyVaultProvider azureKeyVaultProvider = new SqlColumnEncryptionAzureKeyVaultProvider();
SqlColumnEncryptionAzureKeyVaultProvider azureKeyVaultProvider = new SqlColumnEncryptionAzureKeyVaultProvider(new DefaultAzureCredential());
Comment thread
ErikEJ marked this conversation as resolved.
customKeyStoreProviders.Add(SqlColumnEncryptionAzureKeyVaultProvider.ProviderName, azureKeyVaultProvider);
// Registers the provider on the connection
// These providers will take precedence over globally registered providers
Expand All @@ -21,3 +29,17 @@ static void Main()
}
}
// </Snippet1>

class MyCustomKeyStoreProvider : SqlColumnEncryptionKeyStoreProvider
Comment thread
ErikEJ marked this conversation as resolved.
{
public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] encryptedColumnEncryptionKey)
{
// Custom decryption logic here
return new byte[0];
}
public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] columnEncryptionKey)
{
// Custom encryption logic here
return new byte[0];
}
}
Comment thread
ErikEJ marked this conversation as resolved.
9 changes: 6 additions & 3 deletions doc/samples/RegisterCustomKeyStoreProvider_Example.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// <Snippet1>
namespace RegisterCustomKeyStoreProvider_Example;

// <Snippet1>
using Azure.Identity;
using Microsoft.Data.SqlClient;
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;
using System.Collections.Generic;
Expand All @@ -15,7 +18,7 @@ void ExecuteSelectQuery(object user, SqlConnection connection)
if (azureKeyVaultProvider is null)
{
// Create a new SqlColumnEncryptionAzureKeyVaultProvider with the user's credentials and save it for future use
azureKeyVaultProvider = new SqlColumnEncryptionAzureKeyVaultProvider();
azureKeyVaultProvider = new SqlColumnEncryptionAzureKeyVaultProvider(new DefaultAzureCredential());
Comment thread
ErikEJ marked this conversation as resolved.
providerByUser[user] = azureKeyVaultProvider;
}

Expand All @@ -35,7 +38,7 @@ void ExecuteUpdateQuery(object user, SqlConnection connection)
if (azureKeyVaultProvider is null)
{
// Create a new SqlColumnEncryptionAzureKeyVaultProvider with the user's credentials and save it for future use
azureKeyVaultProvider = new SqlColumnEncryptionAzureKeyVaultProvider();
azureKeyVaultProvider = new SqlColumnEncryptionAzureKeyVaultProvider(new DefaultAzureCredential());
Comment thread
ErikEJ marked this conversation as resolved.
providerByUser[user] = azureKeyVaultProvider;
}

Expand Down
Loading
Loading