如何从SharePoint 2010中的数据库中找到SharePoint列表的字段? [英] How could I find the fields of a SharePoint list from database in SharePoint 2010?

查看:80
本文介绍了如何从SharePoint 2010中的数据库中找到SharePoint列表的字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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列表在SharePoint 2010中的数据库具有哪些字段?或者,如果可能的话,如何像以前一样将此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?

我希望这个问题是明确的(对其可能性tbh希望不大.)

I hope the question is clear (have little hope about its possibility tbh).

谢谢

推荐答案

我只分享了下面的方法,尽管没有隔离,它现在可以从中提取xml,尽管所得结果的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列表的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆