I'm currently using this code fragment to retrieve the one xml value that will be returned from my scalar query.
using (SqlDataReader reader = sqlCommand.ExecuteReader())
{
while (reader.Read())
{
SqlXml xml = reader.GetSqlXml(0);
XmlSchema xmlSchema = XmlSchema.Read(xml.CreateReader(), validationEvent);
break;
}
}
I would prefer to use sqlCommand.ExecuteScalar()
but it seems that to do that means bringing back to the xml into a String
which seems wrongheaded to me, since I'm not interested in having a String
.