以下查询是我从旧应用程序继承的,它将2个属性添加到存储在数据库中的Excel中。
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
返回以
开头的XML<sst-statement num="1" mailsort="32" pages="0">
现在,SQL需要转换为LINQ语句。这可能与此查询类似,或者从数据库中检索XML然后更改XML会更好吗?
答案 0 :(得分:1)
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
变成了
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++;
}
我认为:)