-
Notifications
You must be signed in to change notification settings - Fork 96
RazorPageApp
The GitHub repo contains an example ASP.NET Core Razor Pages application. If you clone the EfCore.GenericServices repo and press F5 then it will start. It uses a SQLite in-memory so that it will run anywhere (Windows, Mac and Linux), and always starts with a known set of data.
NOTE: I use the term DTO (also known as a ViewModel) to mean a class containing a set of read/write
properties that has been mapped to an entity class via the ILinkToEntity<TEntity>
interface.
The example application uses a mixture of approaches so that you can see them in action. Here are the examples of various commands.
There are two uses of this. The simplest is ReadManyNoTracked<AuthorWithBookCountDto>
in
Author\Index.cshtml.cs which just shows the Author's name and the number of books they have authored.
The Book list is more complex, and can be found in
Home\Index.cshtml.cs
It uses ReadManyNoTracked<BookListDto>
method to produce the Select
part of the query.
This particular query needs a PerDtoConfig
class called
BookListDtoConfig
to set up the AutoMapper Read mapping to get it to work.
This is used in many of the update methods to show the initial display needed for an update. There are two forms: using an entity class or using a DTO.
I use one mapped to an entity class (Author
) in ???
There are many examples using the DTO version. Have a look at
/Home/AddReview.cshtml.cs, or any of the update in the Pages/Home
directory.
This command will apply an update to an entity.