MVC 4 WebApi サービスを照会しようとすると、次のエラーが発生します。
Extra content at the end of the document
Below is a rendering of the page up to the first error.
55Author Namehttp://images.myserver.com/authorspictures/nophoto.jpg
Linq To Sql によって生成された Author クラスを調べたところ、画像 URL の直後にある Author オブジェクトの次のプロパティが次のプロパティであることがわかりました。
[Association(Name = "Author_Quote", Storage = "_Quotes", ThisKey = "Id", OtherKey = "AuthorId")]
public EntitySet<Quote> Quotes { get; set; }
私の理解では、このプロパティの XML を生成するときに問題が発生し、上記のエラーが発生します。ただし、それを防ぎ、正しく機能させる方法がわかりません。webApi に関して私が見つけたほとんどの例は POCO リストを使用していたため、この問題については役に立ちません。
何かアドバイスはありますか?
以下は私のコードです
public class AuthorController : ApiController
{
IAuthorRepository repository;
public AuthorController(IAuthorRepository repository)
{
this.repository = repository;
}
[ResultLimit(20)]
public IQueryable<Author> GetAuthors(){
return repository.GetAuthors();
}
}
public class DBAuthorRepository : IAuthorRepository
{
public IQueryable<Author> GetAuthors()
{
using (var context = new QuotesDataContext())
{
return context.Authors.ToList().AsQueryable();
}
}
}