Mat*_*att 3 .net c# sharepoint wcf moss
嗨,谢谢你的期待!
我继承了一个基于SharePoint 2007的旧.NET项目,并设计了外部核心库,只访问SP数据,因此SP只是一个后端.是的,我知道迁移到SQL会更好,但客户端不同意.
以前的开发人员使用简单的read方法来读取SP列表中的数据:
SPList list = CurrentRootWeb.Lists["SomeListName"];
Run Code Online (Sandbox Code Playgroud)
然后他们通过排序字典访问列表属性(即列表中的每个项目,获取项目["SomeValue"]).
我不熟悉SharePoint,因此我不知道这是否是访问其数据的最有效方式.
如何在SharePoint中读取具有多个值的LookUp字段?
他们要求的每个属性似乎都需要一个字符串作为回报.所以item[SomeString]
没关系,但是item[SomeList]
让一切都变得棒子!我原以为多值查找列表列是一个包含选定值的序列化或分隔字符串(例如:"red; blue; green").我错过了什么?
谢谢!
小智 9
如果您对具有多个值的LookUp字段特别感兴趣,而不仅仅是MultiChoice feilds,那么以下代码应该有所帮助:
item.Fields["LookFieldName"].Type == SPFieldType.Lookup;
SPFieldLookup LookUpField = item.Fields["LookFieldName"] as SPFieldLookup;
if (LookUpField.AllowMultipleValues)
{
SPFieldLookupValueCollection valueCollection = item[Field.Id] as SPFieldLookupValueCollection;
string[] arrLookupValues = (from SPFieldLookupValue val in valueCollection select val.LookupValue).ToArray<string>();
}
Run Code Online (Sandbox Code Playgroud)