本文介绍了OData REST过滤器,用于深度嵌套的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正常的REST请求,该请求返回了一个很大的结果集合. (在这里修剪)

I have a working REST request that returns a large results collection. (trimmed here)

原始网址是:

http://intranet.domain.com//_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='domain\kens'&$select=AccountName,DisplayName,Email,Title,UserProfileProperties

响应为:

{
"d": {
    "__metadata": {
        "id": "stuff",
        "uri": "morestuff",
        "type": "SP.UserProfiles.PersonProperties"
    },
    "AccountName": "domain\\KenS",
    "DisplayName": "Ken Sanchez",
    "Email": "[email protected]",
    "Title": "Research Assistant",
    "UserProfileProperties": {
        "results": [
            {
                "__metadata": {
                    "type": "SP.KeyValue"
                },
                "Key": "UserProfile_GUID",
                "Value": "1c419284-604e-41a8-906f-ac34fd4068ab",
                "ValueType": "Edm.String"
            },
            {
                "__metadata": {
                    "type": "SP.KeyValue"
                },
                "Key": "SID",
                "Value": "S-1-5-21-2740942301-4273591597-3258045437-1132",
                "ValueType": "Edm.String"
            },
            {
                "__metadata": {
                    "type": "SP.KeyValue"
                },
                "Key": "ADGuid",
                "Value": "",
                "ValueType": "Edm.String"
            },
            {
                "__metadata": {
                    "type": "SP.KeyValue"
                },
                "Key": "AccountName",
                "Value": "domain\\KenS",
                "ValueType": "Edm.String"
            }...

是否可以使用仅返回结果集合(其中Key = SID或Key =其他值)中的键值的$ filter更改REST请求?

Is it possible to change the REST request with a $filter that only returns the Key Values from the results collection where Key=SID OR Key= other values?

按名称,我只需要约3个值.

I only need about 3 values from the results collection by name.

推荐答案

在OData中,您无法过滤内部供稿.

In OData, you can't filter an inner feed.

相反,您可以尝试查询UserProfileProperties来自的实体集,并展开关联的SP.UserProfiles.PersonProperties实体.

Instead you could try to query the entity set that UserProfileProperties comes from and expand the associated SP.UserProfiles.PersonProperties entity.

语法需要针对您的情况进行调整,但是我在考虑以下方面:

The syntax will need to be adjusted for your scenario, but I'm thinking something along these lines:

service.svc/UserProfileProperties?$filter=Key eq 'SID' and RelatedPersonProperties/AccountName eq 'domain\kens'&$expand=RelatedPersonProperties

假设您有一个UserProfileProperties的顶级实体集,并且每个实体都通过一个名为(在我的示例中)RelatedPersonProperties的导航属性绑定到单个SP.UserProfiles.PersonProperties实体.

That assumes you have a top-level entity set of UserProfileProperties and each is tied back to a single SP.UserProfiles.PersonProperties entity via a navigation property called (in my example) RelatedPersonProperties.

这篇关于OData REST过滤器,用于深度嵌套的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 03:56