It's been a while since I followed up on this but I was told by another member of my team that it was working.
Now I am told that it is not working and its very important.....
Code for setting the expression....
protected virtual void EncryptField(IEntityField2 field)
{
if (FieldIsEncrypted(field))
{
if (field.IsChanged)
{
string cert = FieldEncryptionCert(field);
if (cert.Trim().Length > 0)
{
// Now build replacement expression for insert...
// ENCRYPTBYCERT(Cert_ID('#insert cert name here #'),'#insert field value here#'))
DbFunctionCall certId = new DbFunctionCall("CERT_ID", new object[] { cert });
field.SetExpression(new DbFunctionCall("ENCRYPTBYCERT", new object[] { certId, field.CurrentValue }));
}
}
}
}
Code to call EncryptField...
protected override void OnBeforeEntitySave()
{
base.OnBeforeEntitySave();
// Set database Encryption expressions on fields
// that we are encrypting at the database level.....
base.EncryptField(Fields[(int)CarrierOnlineAccessFieldIndex.Password]);
}
Code where entity is added to the UOW...
foreach (CommonEntityBase item in list)
{
if (item.IsDirty )
{
uow.AddForSave(item, null, false, false);
}
}