public static void SetStorageValues(DbConnection connection, string parameterPrefix, string key, byte[] sid, StorageValues values)
        {
            ConnectionState state = connection.State;

            if ((state & ConnectionState.Open) != ConnectionState.Open)
            {
                connection.Open();
            }

            try
            {
                byte[] buffer = values == null ? new byte[0] : values.Serialize();

                DbCommand command = connection.CreateCommand();
                command.CommandText = "dbo.SYS_setFilterValues";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection  = connection;

                DbParameter parameter;
                parameter = command.CreateParameter();
                parameter.ParameterName = parameterPrefix + "key";
                parameter.DbType        = DbType.String;
                parameter.Value         = key;
                command.Parameters.Add(parameter);

                parameter = command.CreateParameter();
                parameter.ParameterName = parameterPrefix + "BinarySid";
                parameter.DbType        = DbType.Binary;
                parameter.Value         = sid;
                command.Parameters.Add(parameter);

                parameter = command.CreateParameter();
                parameter.ParameterName = parameterPrefix + "UserSid";
                parameter.DbType        = DbType.String;
                parameter.Value         = User.GetSID();
                command.Parameters.Add(parameter);

                parameter = command.CreateParameter();
                parameter.ParameterName = parameterPrefix + "values";
                parameter.DbType        = DbType.Binary;
                parameter.Value         = buffer;
                parameter.IsNullable    = true;
                command.Parameters.Add(parameter);

                command.ExecuteScalar();
            }
            finally
            {
                if ((state & ConnectionState.Open) != ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }
 public static void SetStorageValues(string key, byte[] sid, StorageValues values)
 {
     WebInitializer.Initialize();
     SetStorageValues(SpecificInstances.DbFactory.CreateConnection(), SpecificInstances.DbConstants.SqlParameterPrefix, key, sid, values);
 }