How to: Create the SqlParameterDefinition Class
The SQL Query Filter uses the SqlParameterDefinition class to get, set, serialize, or deserialize an SQL statement. Both the client and the server use this class to store, display, run, or read the SQL statement that defines an SQL Query Filter. Depending on the functionality of your filter, you may need to implement a similar class. For more information about filters, see Filters Overview.
Prerequisites
Before you compile the code example, ensure you have met the following prerequisites:
Install PerformancePoint Monitoring Server.
Install the SQL Query Filter sample. To download the sample, see Creating a Custom Dashboard Filter for PerformancePoint Server 2007 ~ Code Sample.
Be prepared to sign your DLL with a strong name. In addition, ensure that all assemblies referenced by your DLL have strong names. For information about how to sign an assembly with a strong name and how to create a public/private key pair, see How to: Create a Public/Private KeyPair.
Example
using System;
using System.IO;
using System.Text;
using System.Xml.Serialization;
namespace SqlQueryParameterProvider
{
[Serializable]
public class SqlParameterDefinition
{
private static XmlSerializer xmlSerializer = null;
private string _expression;
// Clear the filter definition.
public SqlParameterDefinition()
{
_expression = string.Empty;
}
// Get or set the filter definition.
public string Expression
{
get { return _expression; }
set { _expression = value; }
}
// Deserialize the XML string.
public static SqlParameterDefinition Deserialize(string xml)
{
if (!string.IsNullOrEmpty(xml))
{
if (xmlSerializer == null)
xmlSerializer = new XmlSerializer(typeof(SqlParameterDefinition));
SqlParameterDefinition data;
using (TextReader reader = new StringReader(xml))
{
data = (SqlParameterDefinition)xmlSerializer.Deserialize(reader);
reader.Close();
}
return data;
}
return null;
}
// Serialize the filter definition.
public static string Serialize(SqlParameterDefinition data)
{
if (data != null)
{
if (xmlSerializer == null)
xmlSerializer = new XmlSerializer(typeof(SqlParameterDefinition));
StringBuilder xml = new StringBuilder();
using (StringWriter writer = new StringWriter(xml))
{
xmlSerializer.Serialize(writer, data);
writer.Close();
}
return xml.ToString();
}
return null;
}
}
}