Home

How to write this query using LINQ?

Here is a query I am working with in SQLServer 2008.
SELECT ProcessXML.value(N'(/InstantQuoteModel/ContactEmail)[1]','NVARCHAR(100)'), XmlLogId, UserId FROM XmlLogTable 
WHERE ProcessXML.value(N'(/InstantQuoteModel/ContactEmail)[1]','NVARCHAR(100)') ='myemailaddress@email.com'
order by 1 desc
go


How can I write this in LinqPad?

Thanks,
Abhijit

Comments

  • I have solved this by parsing the XML to a string.

    Here is my elegant solution.
    var ci = from xml in XmlLog
    	      where xml.ProcessXml.ToString().Contains("<InstantQuoteModel>")
    		  && xml.ProcessXml.ToString().Contains("myemailaddress@email.com")
    		  && xml.XmlLogId > 1133006
    		  select xml;
    
    ci.Take(100).Dump();
    
Sign In or Register to comment.