SPFieldLink.Id 属性
获取标识该字段引用的 GUID。
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public ReadOnly Property Id As Guid
Get
用法
Dim instance As SPFieldLink
Dim value As Guid
value = instance.Id
public Guid Id { get; }
属性值
类型:System.Guid
该字段引用的唯一标识符。
备注
此属性的值等同于Id属性对应于该字段引用的字段的值。到内容类型的SPFieldCollection属性,以及其SPFieldLinkCollection属性,可以作为索引使用该属性值。
示例
下面的示例演示一个循环访问内容类型SPFieldCollection并打印SPField.Id属性的值,并向控制台的相应SPFieldLink.Id属性的值的控制台应用程序。
Imports System
Imports Microsoft.SharePoint
Module ConsoleApp
Sub Main()
Dim site As SPSite = New SPSite("https://localhost")
Try
Dim web As SPWeb = site.OpenWeb()
Try
Dim contentType As SPContentType = web.ContentTypes("Item")
For Each field As SPField In contentType.Fields
Dim link As SPFieldLink = contentType.FieldLinks(field.Id)
Console.WriteLine("Field.Id = {0}", field.Id)
Console.WriteLine("FieldLink.Id = {0}", link.Id)
Console.WriteLine()
Next field
Finally
web.Dispose()
End Try
Finally
site.Dispose()
End Try
Console.Write("Press ENTER to continue...")
Console.ReadLine()
End Sub
End Module
using System;
using Microsoft.SharePoint;
namespace Test
{
class ConsoleApp
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
SPContentType contentType = web.ContentTypes["Item"];
foreach (SPField field in contentType.Fields)
{
SPFieldLink link = contentType.FieldLinks[field.Id];
Console.WriteLine("SPField.Id = {0}", field.Id);
Console.WriteLine("SPFieldLink.Id = {0}", link.Id);
Console.WriteLine();
}
}
}
Console.Write("Press ENTER to continue...");
Console.ReadLine();
}
}
}
应用程序将以下输出显示到控制台上。
Field.Id = c042a256-787d-4a6f-8a8a-cf6ab767f12d
FieldLink.Id = c042a256-787d-4a6f-8a8a-cf6ab767f12d
Field.Id = fa564e0f-0c70-4ab9-b863-0177e6ddd247
FieldLink.Id = fa564e0f-0c70-4ab9-b863-0177e6ddd247
Press ENTER to continue...