按查找值获取sharepoint列表项
我有测试和方法列表 测试: 测试名 测试1 方法: MethodName,TestName查找wit 方法1,测试1 方法2,测试2 测试名 我想用caml查询按查找值筛选方法按查找值获取sharepoint列表项,sharepoint,caml,Sharepoint,Caml,我有测试和方法列表 测试: 测试名 测试1 方法: MethodName,TestName查找wit 方法1,测试1 方法2,测试2 测试名 我想用caml查询按查找值筛选方法 var metodList = web.Lists["Methods"]; query.Query = @"<Where><Eq><FieldRef Name='TestName'/> <Value Ty
var metodList = web.Lists["Methods"];
query.Query = @"<Where><Eq><FieldRef Name='TestName'/>
<Value Type='Lookup'>Test1</Value></Eq></Where>";
var metods = metodList.GetItems(query);
foreach (SPListItem metodItem in metods.List.Items)
{
metodViewModelList.Add(new MetodViewModel
{
MetodId = Convert.ToInt32(metodItem["ID"]),
MetodName = metodItem["MethodName"].ToString()
});
}
但它不起作用。metods.List.items有两个项。方法2也来了
我哪里做错了?试试:
string lkp_metod = metodItem["TestName"].ToString();
SPFieldLookupValue lkp_metod_value = new SPFieldLookupValue(lkp_metod);
MetodId = lkp_metod_value.LookupId.ToString();
MetodName = lkp_metod_value.LookupValue.ToString();
我不确定是否删除您的答案,因为只有代码。但我建议你们写一些描述,说明你们的答案将如何解决OP问题。这不是我的问题,我想通过查找项目值进行筛选。但是caml查询不起作用。我认为您可以进行查询,但是您可以尝试使用SharePoint创建视图,然后使用这种方法提取caml模式:这将有助于找到错误。