如果我从浏览器使用我的服务操作,它会完美运行。
如果我从 .net 客户端使用我的服务操作,它会给我一个错误
“'System.Linq.IQueryable`1[MyEntity]' 类型没有可设置的属性。”
任何的想法?谢谢。
客户端代码:
public IQueryable<MyEntity> CallMyOperation(string param1 = "", string param2 = "") {
DataServiceQuery<IQueryable<MyEntity>> q =
CreateQuery<IQueryable<MyEntity>>("MyOperation")
.AddQueryOption("param1", "'" + param1 + "'")
.AddQueryOption("param2", "'" + param2 + "'");
return
Execute<IQueryable<MyEntity>>(
new Uri(q.RequestUri.ToString().Replace("MyOperation()", "MyOperation"))).
FirstOrDefault();
}
Wcf 服务代码:
[WebGet]
public IQueryable<MyEntity> MyOperation(string param1 = "", string param2 = "") {
...
}
public static void InitializeService(DataServiceConfiguration config) {
config.DataServiceBehavior.MaxProtocolVersion =
DataServiceProtocolVersion.V3;
config.UseVerboseErrors = true;
config.SetEntitySetAccessRule("MyEntity", EntitySetRights.AllRead);
config.SetServiceOperationAccessRule("MyOperation", ServiceOperationRights.AllRead);
}