【问题标题】:WCF RIA Services - Query with paramWCF RIA 服务 - 使用参数查询
【发布时间】:2012-07-18 06:04:14
【问题描述】:

我正在通过 WCF RIA 服务处理我的数据。我通过 RIA 查询公开我的数据,它工作正常。 现在我需要获取参数化查询方法。我在服务器端的查询方法中添加了参数:

public IQueryable<User> GetUsers(string param1)
{
    return _dataContext.Users;
}

.. 并在客户端上传递参数值:

var query = _context.GetUsersQuery("a");
_context.Load(query, LoadBehavior.MergeIntoCurrent,
                            (LoadOperation lo) =>
                            {
                                if (lo.HasError == false)
                                {
                                    ResultList.ItemsSource = lo.Entities;
                                }

                            }, null);

因此,当我尝试获取数据时,我会在客户端收到 NullReferenceExeption。 是 WCF RIA 服务的已知错误还是我遗漏了什么?

【问题讨论】:

  • NullReference 到底发生在哪里?哪条线?也许在将_dataContext.Users 的结果发送回客户端之前检查它的结果。你没有做任何明显错误的事情。

标签: wcf-ria-services


【解决方案1】:

看起来它是 null 的 ResultList - 确保在运行查询之前对其进行初始化

【讨论】:

    猜你喜欢
    • 2011-11-20
    • 1970-01-01
    • 1970-01-01
    • 2011-04-22
    • 1970-01-01
    • 2012-01-14
    • 1970-01-01
    • 2011-01-29
    • 2011-03-14
    相关资源
    最近更新 更多