workabyte
workabyte

Reputation: 3755

Strong Type Data Set : Override column get : set

we are using data sets as our data access layer. currently there are some columns that store encrypted data.

using CLR i was able to create an SQL function for decryption of the data in a select but in discussion we have determined that to be a security risk.

what i am looking to do is to either

  1. override the get/set of the data table column so that when on the get it will un encrypt the value and return a readable string and on the set will encrypt the data.
  2. or do something with the table adapter so that on the select / update would do the same as above.

Upvotes: 2

Views: 1054

Answers (2)

Artemix
Artemix

Reputation: 2161

You may try to create an extension methods for this task:

namespace ExtensionMethods
{
    public static class MyExtensions
    {
        public static void SetEncryptColumn(this DataSetType.DataTableRow row, string value)
        {
            row.Encrypt = EncryptValue(value);
        }

        public static string GetEncryptColumn(this DataSetType.DataTableRow row)
        {
            return DecryptValue(row.Encrypt);
        }
    }   
}

http://msdn.microsoft.com/en-us/library/bb383977%28v=vs.90%29.aspx

Upvotes: 2

Panagiotis Kanavos
Panagiotis Kanavos

Reputation: 131180

Typed DataTables are partial classes. While you can't override a property, you can add more methods in another file that will encrypt on set and decrypt on get, storing the values in the original properties.

Upvotes: 0

Related Questions