本文整理汇总了C#中FieldCollection.GetById方法的典型用法代码示例。如果您正苦于以下问题:C# FieldCollection.GetById方法的具体用法?C# FieldCollection.GetById怎么用?C# FieldCollection.GetById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldCollection
的用法示例。
在下文中一共展示了FieldCollection.GetById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindField
private Field FindField(FieldCollection fields, ContentTypeFieldLinkDefinition listFieldLinkModel)
{
var context = fields.Context;
var scope = new ExceptionHandlingScope(context);
Field field = null;
if (listFieldLinkModel.FieldId.HasGuidValue())
{
var id = listFieldLinkModel.FieldId.Value;
using (scope.StartScope())
{
using (scope.StartTry())
{
fields.GetById(id);
}
using (scope.StartCatch())
{
}
}
}
else if (!string.IsNullOrEmpty(listFieldLinkModel.FieldInternalName))
{
var fieldInternalName = listFieldLinkModel.FieldInternalName;
using (scope.StartScope())
{
using (scope.StartTry())
{
fields.GetByInternalNameOrTitle(fieldInternalName);
}
using (scope.StartCatch())
{
}
}
}
context.ExecuteQueryWithTrace();
if (!scope.HasException)
{
if (listFieldLinkModel.FieldId.HasGuidValue())
{
field = fields.GetById(listFieldLinkModel.FieldId.Value);
}
else if (!string.IsNullOrEmpty(listFieldLinkModel.FieldInternalName))
{
field = fields.GetByInternalNameOrTitle(listFieldLinkModel.FieldInternalName);
}
context.Load(field);
context.Load(field, f => f.SchemaXml);
context.ExecuteQueryWithTrace();
}
return field;
}
示例2: GetPrimaryLookupField
protected virtual FieldLookup GetPrimaryLookupField(FieldCollection fields, DependentLookupFieldDefinition definition)
{
var context = fields.Context;
Field result = null;
if (definition.PrimaryLookupFieldId.HasGuidValue())
result = fields.GetById(definition.PrimaryLookupFieldId.Value);
if (!string.IsNullOrEmpty(definition.PrimaryLookupFieldInternalName))
result = fields.GetByInternalNameOrTitle(definition.PrimaryLookupFieldInternalName);
if (!string.IsNullOrEmpty(definition.PrimaryLookupFieldTitle))
result = fields.GetByTitle(definition.PrimaryLookupFieldTitle);
context.Load(result);
context.ExecuteQuery();
return context.CastTo<FieldLookup>(result);
}
示例3: Read
private SPOField Read(FieldCollection fields)
{
var ctx = SPOSiteContext.CurrentSiteContext.Context;
Field field = null;
if (this.FieldId != Guid.Empty)
{
field = fields.GetById(this.FieldId);
}
else if (!string.IsNullOrEmpty(this.FieldNameOrTitle))
{
field = fields.GetByInternalNameOrTitle(this.FieldNameOrTitle);
}
if (field != null)
{
_field = field;
ctx.Load(field);
ctx.ExecuteQuery();
if (field.ServerObjectIsNull.Value)
return null;
return new SPOField(_field);
}
return null;
}
示例4: GetField
internal static SPOField GetField(CmdletContext ctx, FieldCollection fields, XmlDocument schemaXmlDoc)
{
Guid fieldId = Guid.Parse(schemaXmlDoc.DocumentElement.GetAttribute("Id"));
Field field = fields.GetById(fieldId);
ctx.Load(field);
ctx.ExecuteQuery();
if (!field.ServerObjectIsNull.Value)
{
return new SPOField(field);
}
field = fields.GetByInternalNameOrTitle(schemaXmlDoc.DocumentElement.GetAttribute("Name"));
ctx.Load(field);
ctx.ExecuteQuery();
if (!field.ServerObjectIsNull.Value)
{
return new SPOField(field);
}
return null;
}