English 中文(简体)
Netflix OData: 简单查询利用航行财产数目
原标题:Netflix OData: Simple query using the Count of a navigation property

我正在通过利用LINQPad查询现有的OData饲料,了解OData。 利用Netflix馈赠,我试图获得一份获赔最多的行动者名单,但我正在经历奇怪的例外。 我的第一次尝试是:

People.OrderByDescending(p => p.Awards.Count).Take(10)

但是,这给我一个<代码>5Dataservice QueryException,但内有例外:

没有财产类型 System.Collections.Generic.ICollection'1[[Netflix.Catalog.v2.Entities]。 标题Award, Netflix.Catalog.v2, FCCC/SBI/2007/8, 第7页。

我试图用<代码>.Count()推广方法而不是<代码>来改变情况。 不动产:

People.OrderByDescending(p => p.Awards.Count()).Take(10)

但是,这只是玩:,我是英瓦利德卡斯特约会:

Unable to cast object of type System.Linq.Expressions.PropertyExpression to type System.Data.Services.Client.ResourceExpression .

at System.Data.Services.Client.ResourceBinder.AnalyzeCountMethod(MethodCallExpression mce)
at System.Data.Services.Client.ResourceBinder.VisitMethodCall(MethodCallExpression mce)
at System.Data.Services.Client.ALinqExpressionVisitor.Visit(Expression exp)
at System.Data.Services.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
at System.Data.Services.Client.ALinqExpressionVisitor.VisitLambda(LambdaExpression lambda)
at System.Data.Services.Client.ALinqExpressionVisitor.Visit(Expression exp)
at System.Data.Services.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
at System.Data.Services.Client.ALinqExpressionVisitor.VisitUnary(UnaryExpression u)
at System.Data.Services.Client.ALinqExpressionVisitor.Visit(Expression exp)
at System.Data.Services.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
at System.Data.Services.Client.ALinqExpressionVisitor.VisitExpressionList(ReadOnlyCollection1 original)
at System.Data.Services.Client.ALinqExpressionVisitor.VisitMethodCall(MethodCallExpression m)
at System.Data.Services.Client.ResourceBinder.VisitMethodCall(MethodCallExpression mce)
at System.Data.Services.Client.ALinqExpressionVisitor.Visit(Expression exp)
at System.Data.Services.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
at System.Data.Services.Client.ALinqExpressionVisitor.VisitExpressionList(ReadOnlyCollection
1 original)
at System.Data.Services.Client.ALinqExpressionVisitor.VisitMethodCall(MethodCallExpression m)
at System.Data.Services.Client.ResourceBinder.VisitMethodCall(MethodCallExpression mce)
at System.Data.Services.Client.ALinqExpressionVisitor.Visit(Expression exp)
at System.Data.Services.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
at System.Data.Services.Client.ResourceBinder.Bind(Expression e)
at System.Data.Services.Client.DataServiceQueryProvider.Translate(Expression e)
at System.Data.Services.Client.DataServiceQuery1.Execute()
at System.Data.Services.Client.DataServiceQuery
1.GetEnumerator()
at System.Data.Services.Client.DataServiceQuery`1.System.Collections.IEnumerable.GetEnumerator()

I tried to follow the suggestions at this question but all I got is one of the above two errors.

任何关于如何开展这一简单行动的想法?

最佳回答

You are wanting to make a decision (in this case "order"), based on an aggregate operation (count).
That kind of aggregate operation is not supported in OData queries (for now?).

See this this question for more information: Collection Exists Criteria in WCF Data Services

In the end, you would have to deal with filtering/ordering the data in a different way. At least 2 possible solutions:

  1. Pull more data down to the client, and filter it there.
  2. If you control the server, then you can expose a specialized service operation to return the result (obviously not the case when Netflix is your data source)
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签