wcf数据服务问题
问题描述:
您好,我在自己的应用程序中实现了wcf数据服务,但我却像这样出现错误找不到该网页.
实际上,我创建了如下这样的可查询方法名称
hi i implemented the wcf data service to my application and i am gettin error like this The webpage cannot be found .
actully i create iquerable method name like this follows
public class sample
{
sample()
{
}
public IQueryable GetData()
{
System.Net.WebRequest request = System.Net.WebRequest.Create("url");
return methodname(arg1,ar2);//here actualy retuning the data as iqueryable and to another class
//return null;
}
public class MyCustomDataSource
{
public MyCustomDataSource()
{
sample s = new sample();
s.GetData();
}
}
数据服务如下
the data service as follows
[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class DataService : DataService< MyCustomDataSource >
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(IDataServiceConfiguration config)
{
// TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
// Examples:
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
// config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
//config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
protected override MyCustomDataSource CreateDataSource()
{
MyCustomDataSource source = new MyCustomDataSource();
return source;
}
}
所以请任何人帮我解决该问题,因为这是公司分配的任务,我是实习生,我对此一无所知,所以请帮助并给我建议
so please anyone help me how can i resolve this since this is task assigned in company i am intern i don''t anything about this so please please help and give me suggestion please
答
尝试使用服务操作进行数据检索:
http://msdn.microsoft.com/en-us/library/cc668788.aspx [ ^ ]
注意:根据MSDN,IQueryable:提供了针对未指定数据类型的特定数据源评估查询的功能"
如果返回IQueryable,我认为您应该在自定义数据源上实现自定义linq提供程序,因为odata协议支持特定的odata操作,例如
Try to use service operation for data retrieval:
http://msdn.microsoft.com/en-us/library/cc668788.aspx[^]
note: according MSDN, IQueryable: "Provides functionality to evaluate queries against a specific data source wherein the type of the data is not specified"
If you return IQueryable , I think you should implement custom linq provider over custom data source because odata protocol supports specific odata operations like
过滤器,
order ,