UPDATE. Changed the code to get it into var result and then loop through it and got my string this way.
Hi everybody,
I'd like to execute a SQL Statement that should produce a single XML (string) value back. I am having troubles figuring out the correct way to get the value back.
This is what I've tried but got an error 'Sequence contains more than one element' in run-time:
string commandText = String.Format("select top (1) * from dbo.{0} where {1} = @PrimaryKey for xml path(''), elements absent ;", tableName, primaryKeyName);
SqlParameter primaryKey = new SqlParameter("@PrimaryKey", SqlDbType.Decimal, 17);
primaryKey.Value = (Decimal) id;
originalState = _siriusContext.CoreContext.ExecuteStoreQuery<String>(commandText, primaryKey).Single().ToString();
Do you see how should I adjust that code?
Thanks in advance.
If it's not broken, fix it until it is.
My Blog