public Template GetTemplate(string title)
{
OpenConnection();
_command.CommandText = "SELECT * FROM Templates WHERE Title = @Title";
_command.Parameters.Add(GetParam("@Title", title));
Template template = null;
var binFormatter = new ListBinaryFormatter<string>();
try
{
using (DbDataReader dataReader = _command.ExecuteReader())
{
while (dataReader.Read())
{
template = new Template(binFormatter.Deserialize((byte[]) dataReader["Data"]), title);
}
}
//LOGGING
Logger.Info("Template was obtained");
}
catch (Exception ex)
{
//LOGGING
Logger.Error("Can't get template!",ex);
throw new InvalidOperationException("Can't get template!");
}
finally
{
CloseConnection();
}
return template;
}