I have a custom collection that has own properties.
public interface IPagedList<T>: IList<T>
{
int TotalCount { get; }
}
And I have a class that implemented IPagedList
interface.
public class PagedList<T> : List<T>, IPagedList<T>
{
public PagedList(IQueryable<T> source){
AddRange(source);
}
public int TotalCount { get; private set; }
}
When I used PagedList<T>
class in my web api application, the TotalCount
property does not serialized.
public class EmpolyeeController : ApiController
{
public IHttpActionResult Get()
{
IPagedList<Employee> response = new PagedList<Employee>(Database.GetEmplyees());
return Ok(response);
}
}
The response is like this:
[
{
"Id": "1230a373-af54-4960-951e-143e75313b25",
"Name": "Deric"
}
]
But I want to see TotalCount property in json response.
The property in Raw View as you can see in screencast.
(I think this is a Raw View of IList serialization problem of json.net. How can I add middleware Raw View serailization)