为什么我的 WCF 数据服务集合没有列出?
我正在尝试制作一个简单的 WCF 数据服务。我能够成功访问 scv
文件,但我的 Cars
收藏未列出。我的 scv
的内容是:
[DataServiceKey("VIN")]
public class Car
{
public String VIN { get; set; }
public String Make { get; set; }
public String Model { get; set; }
public int Year { get; set; }
}
public class CarService : DataService<Car>
{
public IQueryable<Car> Cars
{
get
{
return (new List<Car> {
new Car { VIN = "ABC123", Make = "Ford", Model = "F-250", Year = 2000 },
new Car { VIN = "ABC124", Make = "BMW", Model = "Z-3", Year = 2005 },
new Car { VIN = "ABC125", Make = "Audi", Model = "TT", Year = 2008 }
}).AsQueryable();
}
}
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
}
当在浏览器上访问此服务时,我得到:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<service xml:base="http://localhost:60730/CarService.svc/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app">
<workspace>
<atom:title>Default</atom:title>
</workspace>
</service>
看到该集合没有列出。我做错了什么?
I'm trying to make a simple WCF Data Service. I am able to successfully access the scv
file but my Cars
collection doesn't get listed. The content of my scv
is:
[DataServiceKey("VIN")]
public class Car
{
public String VIN { get; set; }
public String Make { get; set; }
public String Model { get; set; }
public int Year { get; set; }
}
public class CarService : DataService<Car>
{
public IQueryable<Car> Cars
{
get
{
return (new List<Car> {
new Car { VIN = "ABC123", Make = "Ford", Model = "F-250", Year = 2000 },
new Car { VIN = "ABC124", Make = "BMW", Model = "Z-3", Year = 2005 },
new Car { VIN = "ABC125", Make = "Audi", Model = "TT", Year = 2008 }
}).AsQueryable();
}
}
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
}
When access this service on the browser I get:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<service xml:base="http://localhost:60730/CarService.svc/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app">
<workspace>
<atom:title>Default</atom:title>
</workspace>
</service>
See that the collection didn't get listed. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Try this instead: