title: Encrypting Decrypting Data via Entity Framework using separate class exposing encrypted/decrypted values: Linq statements fails
body: <p>In addition to my earlier question on entity framework. My purpose is to encrypt the field before saving to DB and Decrypt the fields before reading from DB.I have class (User.cs)  generated from table User(having UserName property(to be encrypted) and I created a separate class SecureUser with UserName property that isencrypted/decrypted as suggested earlier. But I am not sure how to map this new SecureUser class to DB and not the previous POCO class User. My Linq queries fail when I replace UserName with UserName from SecureUser class. I tried doing the same thing with partial classes , same thing happens.
  Any suggestions will be greatly appreciated !</p>
  
  <pre><code>[Table("Users")]
  public class User
  {
  
      #region database table column mapped fields
      [Key]
      [Required]
      public Int32 UserID { set; get; }
  
      [Required]
      [MaxLength(50)]
      public String UserName { set; get; }
  
      [Required]
      public Int32 CustID { set; get; }
  
  //created the separate class as
  public class SecureUser // UserViewModel
  {
      // 
      private readonly User _user;
  
     public SecureUser(User user)
      {
          _user = user;
      }
  
      public string UserName
      {
          get { return Decrypt(_user.UserName); }
          set { _user.UserName = Encrypt(value); }
      }
  </code></pre>
  
  <p>}</p>