public override ErrorLogEntry GetError(string id)
{
if (id == null)
throw new ArgumentNullException("id");
if (id.Length == 0)
throw new ArgumentException(null, "id");
Guid errorGuid;
try
{
errorGuid = new Guid(id);
}
catch (FormatException e)
{
throw new ArgumentException(e.Message, "id", e);
}
const string sql = @"
SELECT
[AllXml]
FROM
[ELMAH_Error]
WHERE
[ErrorId] = @ErrorId";
using (var connection = new SqlCeConnection(ConnectionString))
{
using (var command = new SqlCeCommand(sql, connection))
{
command.Parameters.Add("@ErrorId", SqlDbType.UniqueIdentifier).Value = errorGuid;
connection.Open();
var errorXml = (string)command.ExecuteScalar();
if (errorXml == null)
return null;
var error = ErrorXml.DecodeString(errorXml);
return new ErrorLogEntry(this, id, error);
}
}
}
}