This is a summary of the main parts used to list, detail, create, edit and delete Tags entries directly. This type of services are useful for simple data classes that do not have dependent foreign keys that need to be manipulated before the data class can be written to the database.
In most cases we detail how TagsAsync commands are different to the normal Tag access. You should therefore read the Tags Explanation to give you that background first. The headers contain links to the code on GitHub for you to look at. For most of you the links to the code will be sufficient, but more information is available by clicking on the panel titles.
(see here for code on GitHub)
uses the GenericService's database commands that work directly on the EF data class.
It differs from the TagsController in that it uses async commands which release the web thread while database actions are running.
Async methods are designed to make the web site more scaleable, but they are slightly slower because they create and use multitasking internally.
Click on the panel below to get more details about how this works.
The explanation of the Tags controller describes certain standard parts. In this section we point out what is the same between the TagsController and the TagsAsyncController.
asyncand return Task<ActionResult>
awaitin front of them to release control while waiting
IQueryableresult and whether it is normal or async is defined by the LINQ method on the end. In the PostAsync Controller we use the method .ToListAsync() which returns an async result.
In the Controller the
are called. NOTE:
As explained in the PostAsync Controller panel the
can handle both normal and async commands depending on the LINQ method appended on the end.
Click on the panel below to get more details about how these work.
The explanation of the Tags controller describes certain standard parts. In this section we point out what is the same between the PostsController and the PostAsyncController.
ListService(code) has the LINQ method .AsListAsync() appended to it to return a async result;
DetailServiceAsync(code) services is a one stage service.
new Tag()to provide the initial class for the input form.
DetailServiceAsyncto do that (see
Editaction in TagsController).
Using DI to inject Action parameters (see MVC module that does this) in a Controller is a short and efficient way of injecting specific services to each action. Also by using Generic DI binding (see example from AutoFac) means that the DI can define all the possible service options quickly in its registartion file (see in SampleMvcWebApp)
See the DI section in Posts Explanation page as the rules are the same for both normal and async services.