Always have error “The ObjectContent 1 type failed to serialize the response body…”

后端 未结 4 495
再見小時候
再見小時候 2021-01-02 11:03

I use Web api to retrieve data from the database. I only have 1 table \"tblMessage\" and want to get data from that table.

I set everything up but then when I run th

4条回答
  •  长情又很酷
    2021-01-02 11:56

    Change IEnumerable> to List

    public IEnumerable GetAllMsg()
    {
        return repo.GetAll();
    }
    

    to

    public List GetAllMsg()
    {
        return repo.GetAll();
    }
    

    UPDATE: But beware of getting OutOfMemoryException because this method will store all Message objects in local memory so you have to implement some kind of paging.

提交回复
热议问题