私は非常に単純な.NET 4.0 WebプロジェクトをWPFクライアントとともに作成しました。要求されたリソースにクエリオプションを適用することはできません
ウェブソリューションには、IQueryable<string>
を返すサービス操作を持つWCFデータサービスがあります。
WPFクライアントはそのサービスを参照し、直接クエリでCreateQuery()
と.Take()
を使用してサービス操作を呼び出します。
は残念ながら、私は、次のエラーメッセージが表示されます。
Query options $orderby, $inlinecount, $skip and $top cannot be applied to the requested resource.
私はhttp://localhost:20789/WcfDataService1.svc/GetStrings()?$top=3
を使用してブラウザでサービスを表示すると、私は同じエラーを取得します。
アイデア?ソリューションをどこかにアップロードする必要があるかどうかを教えてください。
ありがとうございます!
WcfDataService1.svc.cs:
namespace WPFTestApplication1
{
[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class WcfDataService1 : DataService<DummyDataSource>
{
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
[WebGet]
public IQueryable<string> GetStrings()
{
var strings = new string[]
{
"aa",
"bb",
"cc",
"dd",
"ee",
"ff",
"gg",
"hh",
"ii",
"jj",
"kk",
"ll"
};
var queryableStrings = strings.AsQueryable();
return queryableStrings;
}
}
public class DummyEntity
{
public int ID { get; set; }
}
public class DummyDataSource
{
//dummy source, just to have WcfDataService1 working
public IQueryable<DummyEntity> Entities { get; set; }
}
}
MainWindow.xaml.cs:(WPF)
public MainWindow()
{
InitializeComponent();
ServiceReference1.DummyDataSource ds = new ServiceReference1.DummyDataSource(new Uri("http://localhost:20789/WcfDataService1.svc/"));
var strings = ds.CreateQuery<string>("GetStrings").Take(3);
//exception occurs here, on enumeration
foreach (var str in strings)
{
MessageBox.Show(str);
}
}
ありがとうございます!これについての参考情報はありますか?答えに追加することはできますか? –
仕様を参照して応答を更新しました。 –