ASP.Net Web API控制器获取请求不起作用

时间:2014-07-03 00:30:21

标签: asp.net asp.net-web-api

我有一个OrderDetails表。我试图获取其所有内容,但它无法正常工作。如果有人可以指出为什么它没有得到任何非常有用的数据。是的,我在OrderDetails表中有数据,连接正常。

OrderDetail.cs

public class OrderDetail
{
    [Key]
    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
    public int odid { get; set; }
    public int oid { get; set; }
    public virtual Order order { get; set; }
    public int pid { get; set; }
    public int qty { get; set; }
    public int total { get; set; }
    public virtual Product Aproduct { get; set; }

}

OrderDetailsController.cs

    private static readonly IOrderDetailRepository _orders = new OrderDetailRepository();
    // GET api/<controller>
    public IEnumerable<OrderDetail> Get()
    {
        return _orders.GetAll();
    }

OrderDetailRepository.cs

    private readonly MediaSoftContext _db;

    public OrderDetailRepository()
    {
        _db = new MediaSoftContext();
    }

    public IEnumerable<OrderDetail> GetAll()
    {
        return _db.OrderDetails;
    }

0 个答案:

没有答案