在.NET Core 2.2中,不支持Always Encrypted。如果需要使用Always Encrypted功能,可以考虑将应用程序升级到.NET Core 3.0或更高版本。
示例代码:
using System;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
namespace AlwaysEncryptedDemo
{
class Program
{
static void Main(string[] args)
{
string connectionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=MyDatabase;Integrated Security=True;Column Encryption Setting=Enabled;";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand("SELECT * FROM Customers", connection))
{
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
string customerId = reader["CustomerId"].ToString();
string firstName = reader["FirstName"].ToString();
string lastName = reader["LastName"].ToString();
Console.WriteLine($"CustomerId: {customerId}, FirstName: {firstName}, LastName: {lastName}");
}
}
}
}
}
}
}
上一篇:不支持"toDF()"