xpo-401704-query-and-shape-data-always-encrypted.md
XPO supports the Always Encrypted feature that allows you to protect sensitive data, such as credit card numbers. This article describes how to enable this feature and how it affects XPO functionality.
Since client applications do not reveal encryption keys to the database engine, many server-side operations do not work with encrypted columns. Refer to the Feature Details section for additional information.
Certain XPO functions do not work with encrypted columns due to Always Encrypted limitations, for example:
Tip
You can sort and group against encrypted columns on the server side if you use the deterministic encryption.
Use the QueryParameterCollection class and overloaded ExecuteXXX methods to specify parameter types: ExecuteNonQuery(String, QueryParameterCollection), ExecuteQuery(String, QueryParameterCollection), ExecuteScalar(String, QueryParameterCollection).
Session session = new Session();
string sql = "delete Categories where CategoryID=@p0";
DevExpress.Xpo.DB.ParameterValue categoryIdParameter = new ParameterValue();
categoryIdParameter.Value = 9;
categoryIdParameter.DBTypeName = "int";
int deeletedRowsCount = session.ExecuteNonQuery(sql, new QueryParameterCollection(
categoryIdParameter
));
Dim session As New Session()
Dim sql As String = "delete Categories where CategoryID=@p0"
Dim categoryIdParameter As DevExpress.Xpo.DB.ParameterValue = New ParameterValue()
categoryIdParameter.Value = 9
categoryIdParameter.DBTypeName = "int"
Dim deeletedRowsCount As Integer = session.ExecuteNonQuery(sql, New QueryParameterCollection(categoryIdParameter))
By convention, parameter names consist of the “p” letter and the serial number: p0, p1, p2… To set custom parameter names, use these overloaded methods: ExecuteNonQuery(String, String[], QueryParameterCollection), ExecuteQuery(String, String[], QueryParameterCollection), ExecuteScalar(String, String[], QueryParameterCollection).
string sql = "delete Categories where CategoryID=@CategoryID";
DevExpress.Xpo.DB.ParameterValue categoryIdParameter = new ParameterValue();
categoryIdParameter.Value = 9;
categoryIdParameter.DBTypeName = "int";
int deeletedRowsCount = session.ExecuteNonQuery(sql, new string[] { "CategoryID" },
new QueryParameterCollection(
categoryIdParameter
));
Dim sql As String = "delete Categories where CategoryID=@CategoryID"
Dim categoryIdParameter As DevExpress.Xpo.DB.ParameterValue = New ParameterValue()
categoryIdParameter.Value = 9
categoryIdParameter.DBTypeName = "int"
Dim deeletedRowsCount As Integer = session.ExecuteNonQuery(sql, New String() { "CategoryID" }, New QueryParameterCollection(categoryIdParameter))