Column Encryption
Posted: Wed 17 Jun 2015 18:57
Hi,
I need help encrypting a single column in a database table. I would like to be able to use within a linq query a property that will contain the decrypted value of a column stored in a database table.
Here is what I have done ...
I have extended a partial class named Login generated by the entity and added a property called UnencryptedPassword
public partial class Login
{
public String UnencryptedPassword
{
get
{
return Cryptography.DecryptTableColumn(this.Password);
}
set
{
this.Password= Cryptography.EncryptTableColumn(value);
}
}
}
Since the datatable does not contain a table property named UnencryptedPassword I have not specified a mapping.. (//[Devart.Data.Linq.Mapping.Column(Name = @"""UnencryptedPassword """)] )
Because I do not specify a mapping the following query compiles but generates an exception when executing..
"Cannot translate a member that is not mapped." ..
int RecordsCount = (from c in context.Logins
where ((c.UnencryptedPassword == Password) && (c.UserName== UserName))
select c).Count();
Since I do not want to use a for loop, What do I need to do to create the proper linq query syntax?
Thank you
I need help encrypting a single column in a database table. I would like to be able to use within a linq query a property that will contain the decrypted value of a column stored in a database table.
Here is what I have done ...
I have extended a partial class named Login generated by the entity and added a property called UnencryptedPassword
public partial class Login
{
public String UnencryptedPassword
{
get
{
return Cryptography.DecryptTableColumn(this.Password);
}
set
{
this.Password= Cryptography.EncryptTableColumn(value);
}
}
}
Since the datatable does not contain a table property named UnencryptedPassword I have not specified a mapping.. (//[Devart.Data.Linq.Mapping.Column(Name = @"""UnencryptedPassword """)] )
Because I do not specify a mapping the following query compiles but generates an exception when executing..
"Cannot translate a member that is not mapped." ..
int RecordsCount = (from c in context.Logins
where ((c.UnencryptedPassword == Password) && (c.UserName== UserName))
select c).Count();
Since I do not want to use a for loop, What do I need to do to create the proper linq query syntax?
Thank you