The following query is something i inherited from an old app that adds 2 attributes to an excel stored in the database.
SELECT
row_number() over(order by id) as num
, [id] as mailsort
, 0 as pages
, [xmlRecord].query('/sst-statement/*')
FROM dbo.RPA200_preproc AS [sst-statement]
WHERE rpatype = 201
ORDER BY id for xml auto
returns an XM开发者_JAVA百科L starting with
<sst-statement num="1" mailsort="32" pages="0">
now, the SQL would need to be translated to a LINQ statement. Is that possible similar to this query or would it be better to retrieve the XML from database and then change the XML?
SELECT
row_number() over(order by id) as num,
[id] as mailsort,
0 as pages,
[xmlRecord].query('/sst-statement/*')
FROM dbo.RPA200_preproc as [sst-statement]
where rpatype = 201
order by id for xml auto
turned into
int i=0;
var Query =
FROM I in dbo.RPA200_preproc
WHERE rpatype = 201
order by id
SELECT I.id;
foreach(var Item in Query)
{
new XElement("sst-statement", new XAttribute("num", i), new XAttribute("mailsort" = Item), new XAttribute("Pages",(int)0));
i++;
}
I think :)
精彩评论