问题描述
在 SharePoint 2003 和 2007 中,有一个名为 AllLists 的表,其中有一个名为 tp_Fields 的列,其中包含一个 xml,其中包含特定列表的所有字段.
In SharePoint 2003 and 2007, there was a table called AllLists which had a column called tp_Fields which contained an xml containing all fields for a specific list.
存储在 tp_Fields 列中的 xml 示例是具有 3 个字段的 SharePoint 列表:
an example of the xml stored in the tp_Fields column would be this for a SharePoint List with 3 fields:
<FieldRef Name="ContentTypeId" />
<FieldRef Name="_ModerationComments" ColName="ntext1" />
<FieldRef Name="WebPartTypeName" ColName="nvarchar9" />
我们有一个应用程序正在使用 C# 代码读取本专栏,例如
We have an application that is reading from this column using C# code e.g.
var tpFields = (String) drView["tp_Fields"];
在 SharePoint 2010 中,此列的数据类型已更改为 varbinary 并且仅包含一些二进制数据!
In SharePoint 2010, the datatype of this column has changed to varbinary and contains just some binary data instead!
(我知道理想/推荐的解决方案是使用 SharePoint Web 服务或 SharePoint 对象模型,而不依赖于基础表,但不幸的是,我们有一个现有的应用程序,我们也需要使其与 2010 一起使用.我希望我们不必重新设计一切!)
(I know the ideal/recommended solution was to use the SharePoint web services or SharePoint object model and not relying on the underlying tables but unfortunately we have an existing app and we'd need to make it work with 2010 as well. I hope we don't have to redesign everything!)
我如何从 SharePoint 2010 中的数据库知道 SharePoint 列表具有哪些字段?或者如果可能的话,如何像以前一样将此 varbinary 列转换为其等效的 xml?
How could I know what fields a SharePoint list has from its database in SharePoint 2010? or if possible how to convert this varbinary column to its equivalent xml like before?
我希望这个问题很清楚(对它的可能性几乎没有希望).
I hope the question is clear (have little hope about its possibility tbh).
谢谢,
推荐答案
只是为了分享,我写了下面的方法,它现在可以从中提取 xml 虽然没有 quarantee 生成的 xml 与 SharePoint 2003/2007 兼容.
Just to share, I wrote the below method and it can now extract the xml from it although there is no quarantee the resulting xml is compatible with SharePoint 2003/2007.
private static string getXmlFromTpFields(byte[] tpFields)
{
using (var memoryStream = new MemoryStream(tpFields))
{
// ignore the first 14 bytes; I'm not sure why but it works!
for (var index = 0; index <= 13; index++)
memoryStream.ReadByte();
var deflateStream = new DeflateStream(memoryStream, CompressionMode.Decompress);
using (var destination = new MemoryStream())
{
deflateStream.CopyTo(destination);
var streamReader = new StreamReader(destination);
destination.Position = 0;
return streamReader.ReadToEnd();
}
}
}
这篇关于如何从 SharePoint 2010 的数据库中找到 SharePoint 列表的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!