1

我需要在 SharePoint 中查询一个列表,将来可能会在其中添加列。例如,目前我有以下列名称,工作,兴趣,地址我希望能够使用浏览器中的参数动态查询此字符串,因此如果将来添加列,我不必更改代码但只是参数。地址可能看起来像这样 www.contoso.com/sites/mypage.aspx?property=Interests 而代码就在这行:

var SiteParameter = Request.QueryString["property"];

var ItemsFromList = from item in ListItems where item[try to put the parameter in here] select item;

我使用 SPmetal 来获取列表详细信息,所以如果我按 item。Visual Studio2010 将返回列表中的列。

4

1 回答 1

0

如果没有 SPMetal,这可能会更容易。

var qy = new SPQuery();
qy.Query =
    "<Where><Eq>" +
        "<FieldRef Name=`" + siteParameter + "'/>" +
        // You may have to worry about the type of the field here, too.
        "<Value Type='Text'>" + desiredValue + "</Value>" + 
    "</Eq></Where>";
var itemCollection = myList.GetItems(qy);
于 2012-07-06T08:17:09.570 回答