Count と LongCount は、クエリの同期実行を必要とするため、Silverligth ではサポートされていません。Silverlight ではすべてのネットワーク操作を非同期にする必要があるため、これは不可能です。
$count は数値のテキスト表現を返すため、応答の解析はそれほど難しくありません。
または、ちょっとしたトリックを使用することもできます。IncludeTotalCount() を使用して、応答にカウントを含めるクエリに $inlinecount=allpages クエリ オプションを追加できます。次に、サーバーからすべてのエンティティをダウンロードしないようにするには、 $top=0 を追加して空の結果セットを返す Take(0) を使用できます。ただし、インライン カウントには正しい数値が含まれます。
QueryOperationResponse.TotalCount プロパティでインライン カウントにアクセスできます。このようなもの:
NetflixCatalog ctx = new NetflixCatalog(new Uri("http://netflix.cloudapp.net/Catalog"));
var q = (DataServiceQuery<Genre>)ctx.Genres.IncludeTotalCount().Take(0);
q.BeginExecute((ar) =>
{
QueryOperationResponse<Genre> r = (QueryOperationResponse<Genre>)q.EndExecute(ar);
r.TotalCount.ToString(); // Use the count in whatever way you need
}, null);