SPContentDatabase 类
代表SharePoint Foundation部署中的内容数据库。
继承层次结构
System.Object
Microsoft.SharePoint.Administration.SPAutoSerializingObject
Microsoft.SharePoint.Administration.SPPersistedObject
Microsoft.SharePoint.Administration.SPPersistedUpgradableObject
Microsoft.SharePoint.Administration.SPDatabase
Microsoft.SharePoint.Administration.SPContentDatabase
命名空间: Microsoft.SharePoint.Administration
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
<GuidAttribute("3D4F5451-1735-48bb-B920-76C1EC240B1D")> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPContentDatabase _
Inherits SPDatabase _
Implements IDatabaseSnapshotRestore, IMigratable
用法
Dim instance As SPContentDatabase
[GuidAttribute("3D4F5451-1735-48bb-B920-76C1EC240B1D")]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPContentDatabase : SPDatabase,
IDatabaseSnapshotRestore, IMigratable
备注
使用SPSite类的或的SPWorkItemCollection类的**ContentDatabase()**属性返回的工作项集合的网站集的内容数据库。使用SPWebApplication类的ContentDatabases属性返回所使用的 Web 应用程序的内容数据库的集合。
使用索引器从内容数据库的集合中返回一个内容数据库。例如,如果该集合分配给名为myContentDatabases的变量中,使用在 C# myContentDatabases[index]或myContentDatabases(index)在 Visual Basic,其中index是集合中的字段的索引号,或是该内容数据库的 GUID。
示例
由当前的更改日志从当前网站集删除用户时,下面的示例使用GetChanges方法来报告。
Dim siteCollection As SPSite = SPContext.Current.Site
Dim contentDB As SPContentDatabase = siteCollection.ContentDatabase
Dim myQuery As New SPChangeQuery(False, False)
myQuery.User = True
myQuery.Delete = True
Dim changes As SPChangeCollection = contentDB.GetChanges(myQuery)
Dim change As SPChange
For Each change In changes
Response.Write((" User deleted: " + change.Time.ToString() + "<BR>"))
Next change
SPSite siteCollection = SPContext.Current.Site;
SPContentDatabase contentDB = siteCollection.ContentDatabase;
SPChangeQuery myQuery = new SPChangeQuery(false, false);
myQuery.User = true;
myQuery.Delete = true;
SPChangeCollection changes = contentDB.GetChanges(myQuery);
foreach (SPChange change in changes)
{
Response.Write(" User deleted: " + change.Time.ToString() + "<BR>");
}
线程安全性
此类型的任何公共静态 (在 Visual Basic 中的Shared ) 成员是安全的多线程操作。不保证实例成员是线程安全。