使用从WCF数据服务的服务操作返回的复杂数据json的问题 [英] Issue in using the complex data json returned via service operation from WCF Data service

查看:82
本文介绍了使用从WCF数据服务的服务操作返回的复杂数据json的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我试图通过我的WCF数据服务的服务操作返回IEnumerable。该操作在浏览器中运行良好并返回json。但是,当我通过jQuery在我的客户端应用程序中使用它时,firefox错误控制台提供了json格式的错误。
以下是我返回复杂数据的代码:

I am trying to return an IEnumerable via my service operation of WCF Data service. The operation runs fine in browser and returns json. However when I consume it in my client app via jQuery, firefox error console gives and error in json format. Below is my code to return complex data:

 


[WebGet]
public IEnumberable<ComplexType> GetNames()
{
  return (this.CurrentdataSource.UserNames
      .Select(x => new {
        ID = x.ID,
        Name = x.Name
      }).ToList()
      .Select(x => new ComplexType {
        ID = x.ID,
        Name = x.Name
      }));
}

推荐答案

您能告诉我们您用于获取结果的代码吗? ,你正在使用哪个版本的jQuery?

Can you show us the code you're using to get the results, and which version of jQuery you are using?

如果你正在使用jQuery来获取OData,我可能还建议使用
http://datajs.codeplex.com/
,它提供了一些更专业的功能。

If you're using jQuery just to get to OData, I might also suggest using http://datajs.codeplex.com/, which provides some more specialized functionality.


这篇关于使用从WCF数据服务的服务操作返回的复杂数据json的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆