XQuery in Linq for objects for Sql server XML data type

I am trying to figure out how to make a Linq To Entities query in a SQL Server database that contains an XML data type:

I want to execute a database level query that returns only the specified XML node that contains more than 2000 characters

Is this possible in Linq To Entities?

Update

Well, I want to do something like this in linq-to-entity, but I don't think its possible

var q = from c in Changes
 where c.Content.XPathSelectElement("OpsNotes").Value.Length >= 2000;
 select c;

inside the sql server database, the XML content is a node called "OpsNotes"

 <Content Type="AP" Version="1">
  <Name>CPU FAIL-OVER</Name>
  <Bands>
    <Band>BAND DATA</Band>
  </Bands>
  <StartTime IsCritical="false" IsTimeSet="true">2009-12-06T14:00:00.0000000Z</StartTime>
  <Duration>00:30:00</Duration>
  <RecurrenceRule>RRULE:[List]{340/2009}</RecurrenceRule>
  <OpsNotes>Rationale: Support standard weekly DVIS CPU fail-over</OpsNotes>
   </Content>
+3
source share
2 answers

I would be surprised if it were possible, directly.

:

  • XML SQL Server XDocument (Linq-to-XML) XmlDocument ( DOM)

  • SQL Server, SQL Server XQuery, , int .. -

XQuery - , XML , ....

: , SQL Server XQuery, - :

var q = from c in Changes   c.Content.XPathSelectElement( "OpsNotes" ). Value.Length >= 2000;   c;

SELECT (list of fields)
FROM dbo.Changes c
WHERE c.Content.value('(string-length(string((/Content/OpsNotes)[1])))', 'int') >= 2000

- .

, .

+1

SQL .

EF 4 ExecuteStoreQuery SQL .

0

Source: https://habr.com/ru/post/1756074/


All Articles