I would need to write a linq query in c# for the following sql query. I have no issues in implementing where, not in, orderby and descending but the problem is to query a sql xml column
SELECT [ID]
,[QueuedTime]
,Parameters.query('data(Root/Root/@type)').value('.', 'varchar(500)') as CommandName //how to implement this line in linq
,[Status]
,[CurrentRetryCount]
,[MaxRetryCount]
,[RetryDelaySeconds]
,[CompletedTime]
,[LastTriedTime]
,[LastError]
,Parameters
,[PrincipalString]
FROM [AppServer].[dbo].[RequestQueue]
where interfacename = 'ICommunicationsService'
and MethodName = 'ProcessCommand'
and status not in (1,2)
order by id desc
The following query will meet where, not in and order by descending conditions. I am concerned about how do I implement 'Parameters.query('data(Root/Root/@type)').value('.', 'varchar(500)') as CommandName' in linq
var unwantedStatus = new[] { 1, 2 };
var operationTimedOutTasks = context.TblRequestQueues
.Where(t => t.MethodName == "ProcessCommand" && !unwantedStatus.Contains(t.Status))
.OrderByDescending(t => t.ID)
.ToList();