查询其子类型的ODATA集

时间:2014-05-23 18:47:03

标签: visual-studio-2013 odata wcf-data-services asp.net-web-api2

我有一个使用WebApi2实现的ODATA服务端点。它公开了一组实体资源。资源是大型资源层次结构的基类。 SystemResource是其子类型之一(换句话说,SystemResource:Resource)。 我的.NET客户端项目(VS2013)引用该ODATA服务并生成与该服务相关的所有代理数据。我可以通过

获取客户端的所有资源
myServiceContainer.Resources 

或    myServiceContainer.Resources.OfType<Resource>()

但是,当我试图通过以下方式获取系统资源时    myServiceContainer.Resources.OfType<SystemResource>()致电 - 请求失败,出现以下异常:System.Data.Services.Client.DataServiceQueryException

任何想法可能出错?我是否错过了任何必需的查询请求配置选项?

提前感谢您的帮助......

这是最内部异常的消息:

"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> \n<html xmlns=\"http://www.w3.org/1999/xhtml\"> \n<head> \n<title>IIS 8.0 Detailed Error - 404.0 - Not Found</title> \n<style type=\"text/css\"> \n<!-- \nbody{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;} \ncode{margin:0;color:#006600;font-size:1.1em;font-weight:bold;} \n.config_source code{font-size:.8em;color:#000000;} \npre{margin:0;font-size:1.4em;word-wrap:break-word;} \nul,ol{margin:10px 0 10px 5px;} \nul.first,ol.first{margin-top:5px;} \nfieldset{padding:0 15px 10px 15px;word-break:break-all;} \n.summary-container fieldset{padding-bottom:5px;margin-top:4px;} \nlegend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;} \nlegend{color:#333333;;margin:4px 0 8px -12px;_margin-top:0px; \nfont-weight:bold;font-size:1em;} \na:link,a:visited{color:#007EFF;font-weight:bold;} \na:hover{text-decoration:none;} \nh1{font-size:2.4em;margin:0;color:#FFF;} \nh2{font-size:1.7em;margin:0;color:#CC0000;} \nh3{font-size:1.4em;margin:10px 0 0 0;color:#CC0000;} \nh4{font-size:1.2em;margin:10px 0 5px 0; \n}#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:\"trebuchet MS\",Verdana,sans-serif; \n color:#FFF;background-color:#5C87B2; \n}#content{margin:0 0 0 2%;position:relative;} \n.summary-container,.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;} \n.content-container p{margin:0 0 10px 0; \n}#details-left{width:35%;float:left;margin-right:2%; \n}#details-right{width:63%;float:left;overflow:hidden; \n}#server_version{width:96%;_height:1px;min-height:1px;margin:0 0 5px 0;padding:11px 2% 8px 2%;color:#FFFFFF; \n background-color:#5A7FA5;border-bottom:1px solid #C1CFDD;border-top:1px solid #4A6C8E;font-weight:normal; \n font-size:1em;color:#FFF;text-align:right; \n}#server_version p{margin:5px 0;} \ntable{margin:4px 0 4px 0;width:100%;border:none;} \ntd,th{vertical-align:top;padding:3px 0;text-align:left;font-weight:normal;border:none;} \nth{width:30%;text-align:right;padding-right:2%;font-weight:bold;} \nthead th{background-color:#ebebeb;width:25%; \n}#details-right th{width:20%;} \ntable tr.alt td,table tr.alt th{} \n.highlight-code{color:#CC0000;font-weight:bold;font-style:italic;} \n.clear{clear:both;} \n.preferred{padding:0 5px 2px 5px;font-weight:normal;background:#006633;color:#FFF;font-size:.8em;} \n--> \n</style> \n \n</head> \n<body> \n<div id=\"content\"> \n<div class=\"content-container\"> \n  <h3>HTTP Error 404.0 - Not Found</h3> \n  <h4>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</h4> \n</div> \n<div class=\"content-container\"> \n <fieldset><h4>Most likely causes:</h4> \n  <ul> \t<li>The directory or file specified does not exist on the Web server.</li> \t<li>The URL contains a typographical error.</li> \t<li>A custom filter or module, such as URLScan, restricts access to the file.</li> </ul> \n </fieldset> \n</div> \n<div class=\"content-container\"> \n <fieldset><h4>Things you can try:</h4> \n  <ul> \t<li>Create the content on the Web server.</li> \t<li>Review the browser URL.</li> \t<li>Check the failed request tracing log and see which module is calling SetStatus. For more information, click <a href=\"http://go.microsoft.com/fwlink/?LinkID=66439\">here</a>. </li> </ul> \n </fieldset> \n</div> \n \n<div class=\"content-container\"> \n <fieldset><h4>Detailed Error Information:</h4> \n  <div id=\"details-left\"> \n   <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> \n    <tr class=\"alt\"><th>Module</th><td>&nbsp;&nbsp;&nbsp;IIS Web Core</td></tr> \n    <tr><th>Notification</th><td>&nbsp;&nbsp;&nbsp;MapRequestHandler</td></tr> \n    <tr class=\"alt\"><th>Handler</th><td>&nbsp;&nbsp;&nbsp;StaticFile</td></tr> \n    <tr><th>Error Code</th><td>&nbsp;&nbsp;&nbsp;0x80070002</td></tr> \n     \n   </table> \n  </div> \n  <div id=\"details-right\"> \n   <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> \n    <tr class=\"alt\"><th>Requested URL</th><td>&nbsp;&nbsp;&nbsp;http://localhost:52305/maxdata/Users/Max.Model.UserGroup()</td></tr> \n    <tr><th>Physical Path</th><td>&nbsp;&nbsp;&nbsp;C:\\WorkspaceGit\\BitCrafters.net\\ZETRON\\Max\\Max.DataServiceWebApi\\maxdata\\Users\\Max.Model.UserGroup()</td></tr> \n    <tr class=\"alt\"><th>Logon Method</th><td>&nbsp;&nbsp;&nbsp;Anonymous</td></tr> \n    <tr><th>Logon User</th><td>&nbsp;&nbsp;&nbsp;Anonymous</td></tr> \n    <tr class=\"alt\"><th>Request Tracing Directory</th><td>&nbsp;&nbsp;&nbsp;C:\\Users\\akornich\\Documents\\IISExpress\\TraceLogFiles\\MAX.DATASERVICEWEBAPI</td></tr> \n   </table> \n   <div class=\"clear\"></div> \n  </div> \n </fieldset> \n</div> \n \n<div class=\"content-container\"> \n <fieldset><h4>More Information:</h4> \n  This error means that the file or directory does not exist on the server. Create the file or directory and try the request again. \n  <p><a href=\"http://go.microsoft.com/fwlink/?LinkID=62293&amp;IIS70Error=404,0,0x80070002,9200\">View more information &raquo;</a></p> \n   \n </fieldset> \n</div> \n</div> \n</body> \n</html> \n"

我猜,关键信息是:

此错误表示服务器上不存在该文件或目录。创建文件或目录并再次尝试请求。

这是否意味着我必须为派生类型添加额外的路由?

0 个答案:

没有答案