QueryInterceptor未触发

时间:2016-03-21 12:16:28

标签: wcf rest odata

我在WCF(在SharePoint中)的数据服务上创建了一个QueryInterceptor。

调用“InitializeService”方法,我可以调试那个, 但我的QueryInterceptors不会被解雇。

[QueryInterceptor("Requests")]
    public Expression<Func<Request, bool>> FilterRequests()
    {
        Debugger.Break();
        if (SPContext.Current == null) throw new DataServiceException(401, "Permission Denied");
        var spUser = SPContext.Current.Web.CurrentUser;
        var spLoginName = spUser.LoginName;
        var spGroups = spUser.Groups.Cast<SPGroup>().Select(x => x.Name);
        if (spGroups.Any(x => x == _HRApproversGroupName))
            return (u) => true;
        throw new DataServiceException(401, "Permission Denied");
    }

public static void InitializeService(DataServiceConfiguration config)
    {
        config.SetEntitySetAccessRule("Users", EntitySetRights.AllRead);
        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
        config.UseVerboseErrors = true;
    }

任何知道我做错了什么或者还没有做过的人?

1 个答案:

答案 0 :(得分:0)

问题是我引用了错误的QueryInterceptor(我引用了另一个程序集,但具有相同的名称空间)