SqlConnection.ColumnEncryptionQueryMetadataCacheEnabled Property

Definition

Gets or sets a value that indicates whether query metadata caching is enabled (true) or not (false) for parameterized queries running against Always Encrypted enabled databases. The default value is true.

C#
public static bool ColumnEncryptionQueryMetadataCacheEnabled { get; set; }

Property Value

Returns true if query metadata caching is enabled; otherwise false. true is the default.

Remarks

For parameterized queries, SqlClient makes a roundtrip to SQL Server for parameter metadata, to see which parameter it needs to encrypt and how (which keys and algorithms should be used). If the application calls the same query multiple times, an extra roundtrip is made to the server each time, which degrades application performance.

With ColumnEncryptionQueryMetadataCacheEnabled set to true, if the same query is called multiple times, the roundtrip to the server will be made only once. The cache has a non-configurable Max size parameter that is set to 2000 queries.

Applies to

Product Versions
.NET Framework 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1