There is another option: you can "hide" the actual property, for example. protectedand add the "fake" property publicto the partial entity class that will encrypt / decrypt this internalin getter / setter, so it will be transparent to the user:
.dbml file:
<Column Name="Password"
Member="PasswordInternal"
AccessModifier="Protected"
Type="System.String"
DbType="Varchar(64) NOT NULL"
CanBeNull="false" />
and then in a partial class:
public partial class YourEntity
{
public string Password
{
get
{
return Crypter.Decrypt(this.PasswordInternal)
}
set
{
this.PasswordInternal = Crypter.Encrypt(value)
}
}
}
source
share