I'm trying to build a function to query a table that uses a column of type XML
.
This is my code:
public int GetTotalQueue(string queueCode)
{
int queueNumber = 0;
QueueEntities _context = new QueueEntities();
try
{
var data = (from a in _context.QueueTable
where a.QueueStatusId == 5
&& a.Workgroup == "Group H"
&& a.ExtraData.Cast<string>().Contains<string>(queueCode)
select a.QueueId).Count();
queueNumber = data;
}
catch (Exception ex)
{
ExceptionHandler(ex);
throw;
}
return queueNumber;
}
Extra data is the XML
type column. I tried casting it to a string to do a contains but when I try to actually run this method in the wcf tester the service just fails with a non descriptive internal error. Does anyone have any suggestions on what I can do to fix this query? Am I messing up my cast? Any help would be appreciated. Thanks!