c# - Can't Get $expand Working for a Single OData Entity With AsyncEntitySetController -
I'm unable to extend $ over a single unit, but it works fine on the archive. I have the following asynchronous OData Web API Controller is:
Public Class Author Controller: AsyncEntitySetController & lt; Author, Int & gt; {Private Readonly IAuthorRepository _AuthorRepo = New Author Repository (); // GET odata / & lt; Controller & gt; [Queryable] Public override async Tasks & lt; IEnumerable & lt; Author & gt; & Gt; Get () {var authors = wait _AuthorRepo.GetAll (); Return Authors ANALIMABLE (); } // GET odata / & lt; Controller & gt; / 5 [queries] Public async works & lt; Author & gt; ([FromODataUri] get the int key) {var author = await _AuthorRepo.GetById (key); Return Author; }} Requesting archiving through the works, and through the expansion of such authors books? $ Extension = does books.
However, while attempting to expand a single unit, what is the above method? $ Extension = Accepts an important parameter through the book, the book generates the following error:
A number of actions that match the request: Go to Type AcmeApi.Controllers.AuthorsController Type AcmeApi.Controllers.AuthorssController
To read the answer, I tried to return a single method to get my second method:
< code> [queries] public single result & lt; Account & gt; ([FromODataUri] get the int key) {return SingleResult.Create & lt; Account & gt; (M_AccountRepo.GetById (key)); } but it is the result of the following compilation error:
argument 1: 'system. Can not change with threading. Linq.IQueryable ''
The asynchronous GetById repository method is:
public async Tasks & lt; Author & gt; GetById (Int ID) {Return Work Tasks. Rouen ((=); _Authors.Where (a => a.Id == ID) .SingleOrDefault ()); } If the method of returning a single result is a way to expand $ to work for an entity, then what is the correct way to do this with the asynchronous controller?
Rename ([FromOdataUri] int key) to GetAuthor ([] int) / Code> can solve this problem
Please see this post :.
Comments
Post a Comment