├── BookApp ├── Views │ ├── _ViewStart.cshtml │ ├── _ViewImports.cshtml │ ├── Admin │ │ ├── BookUpdated.cshtml │ │ ├── ChangePubDate.cshtml │ │ ├── AddBookReview.cshtml │ │ └── ChangePromotion.cshtml │ ├── Shared │ │ ├── _ValidationScriptsPartial.cshtml │ │ ├── Error.cshtml │ │ └── LogModal.cshtml │ ├── Checkout │ │ ├── Index.cshtml │ │ └── PlaceOrder.cshtml │ ├── Home │ │ ├── Privacy.cshtml │ │ └── About.cshtml │ └── Orders │ │ ├── Index.cshtml │ │ ├── ConfirmOrder.cshtml │ │ └── OneOrderPartial.cshtml ├── Startup.cs ├── wwwroot │ ├── favicon.ico │ ├── lib │ │ ├── jquery-validation-unobtrusive │ │ │ └── LICENSE.txt │ │ ├── jquery-validation │ │ │ └── LICENSE.md │ │ ├── bootstrap │ │ │ └── LICENSE │ │ └── jquery │ │ │ └── LICENSE.txt │ └── js │ │ └── bundle.min.js ├── bundleconfig.json ├── appsettings.json ├── appsettings.Development.json ├── Models │ └── ErrorViewModel.cs ├── Controllers │ ├── LoggerController.cs │ ├── BaseTraceController.cs │ └── OrdersController.cs ├── Properties │ └── launchSettings.json ├── Program.cs ├── HelperExtensions │ ├── IsLocalExtension.cs │ └── DatabaseStartupHelpers.cs ├── BookApp.csproj └── Logger │ └── RequestTransientLogger.cs ├── Test ├── appsettings.json ├── Chapter06Listings │ ├── Many1.cs │ ├── Many2.cs │ ├── Many3.cs │ ├── OnePrincipal.cs │ ├── ReviewNotSafe.cs │ ├── OneDependent.cs │ ├── ManyTop.cs │ ├── BookNotSafe.cs │ ├── EfManyExtension.cs │ ├── Chapter06Context.cs │ ├── Employee.cs │ └── EmployeeExtensions.cs ├── Chapter03Listings │ ├── EfCode │ │ ├── SimpleCreateSql.sql │ │ └── Chapter3DbContext.cs │ └── EfClasses │ │ ├── ExampleEntity.cs │ │ ├── TagCheckSet.cs │ │ ├── ReviewSetCheck.cs │ │ ├── Author.cs │ │ ├── BookCheckSet.cs │ │ └── BookAuthorCheckSet.cs ├── Chapter01Listings │ ├── Person.cs │ └── Chapter01DbContext.cs ├── Chapter02Listings │ ├── Lazy1Review.cs │ ├── Lazy2Review.cs │ ├── LazyReview.cs │ ├── LazyProxyContext.cs │ ├── LazyInjectContext.cs │ ├── BookLazyProxy.cs │ ├── BookHashContext.cs │ ├── BookHashReview.cs │ ├── BookLazy2.cs │ └── BookLazy1.cs ├── Mocks │ ├── TransactBizActionDto.cs │ ├── FakeUserIdService.cs │ ├── MockBizAction.cs │ ├── MockHttpCookieAccess.cs │ ├── MockBizActionAsync.cs │ ├── MockBizActionPart1.cs │ ├── MockBizActionPart2.cs │ ├── FakeResponseCookies.cs │ ├── FakeRequestCookieCollection.cs │ ├── MockBizActionWithWrite.cs │ ├── MockBizActionWithWriteAsync.cs │ └── StubPlaceOrderDbAccess.cs ├── UnitCommands │ └── DeleteAllUnitTestDatabases.cs ├── UnitTests │ ├── TestAspNetCore │ │ ├── TestCalculateReviewsToMatch.cs │ │ ├── TestDatabaseSetupHelpers.cs │ │ └── TestBookJsonLoader.cs │ ├── TestServiceLayer │ │ ├── Ch03_CalculateReviewsToMatch.cs │ │ ├── Ch04_RunnerWriteDb.cs │ │ ├── Ch02_BookJsonLoader.cs │ │ ├── Ch04_RunnersAsync.cs │ │ ├── Ch02_Sort.cs │ │ ├── Ch04_RunnerWriteDbWithValidation.cs │ │ ├── Ch04_RunnerWriteDbWithValidationAsync.cs │ │ ├── Ch03_ChangePriceOfferService.cs │ │ ├── Ch02_ListBooksService.cs │ │ └── Ch02_ListSortFilterPageDto.cs │ ├── TestDataLayer │ │ ├── Ch03_SimpleUpdateSql.sql │ │ ├── Ch06_ComplexQueryOperators.cs │ │ └── Ch03_SpliteInMemory.cs │ ├── TestSupportCode │ │ ├── LinqHelpers.cs │ │ ├── Ch04_MockHttpCookieAccess.cs │ │ ├── Ch04_MockPlaceOrderDbAccess.cs │ │ └── Ch02_AppSettings.cs │ └── TestBizDbAccess │ │ └── Ch04_PlaceOrderDbAccess.cs ├── Chapter05Listings │ ├── ExampleSeed.cs │ ├── ExampleProgram.cs │ └── ExampleMigrateDatabase.cs └── Test.csproj ├── DataLayer ├── DataLayer.csproj ├── EfCode │ ├── IUserIdService.cs │ ├── ReplacementUserIdService.cs │ └── ValidationDbContextServiceProvider.cs ├── EfClasses │ ├── Tag.cs │ ├── Author.cs │ ├── Review.cs │ ├── PriceOffer.cs │ ├── Order.cs │ ├── BookAuthor.cs │ └── Book.cs ├── QueryObjects │ └── GenericPaging.cs └── Migrations │ └── 20200921133547_AddTags.cs ├── MyFirstEfCoreApp ├── MyFirstEfCoreApp.csproj ├── Author.cs ├── Book.cs ├── AppDbContext.cs ├── MyLoggerProvider.cs └── Program.cs ├── BizLogic ├── Orders │ ├── IPlaceOrderAction.cs │ ├── IPlaceOrderPart2.cs │ ├── OrderLineItem.cs │ ├── IPlaceOrderPart1.cs │ ├── Part1ToPart2Dto.cs │ ├── PlaceOrderInDto.cs │ └── Concrete │ │ └── PlaceOrderPart1.cs ├── BizLogic.csproj ├── GenericInterfaces │ ├── IBizActionAsync.cs │ ├── IBizAction.cs │ └── BizActionErrors.cs └── AppStart │ └── NetCoreDiSetupExtensions.cs ├── ServiceLayer ├── AdminServices │ ├── IChangePubDateService.cs │ ├── IAddReviewService.cs │ ├── IChangePriceOfferService.cs │ └── ChangePubDateDto.cs ├── Logger │ ├── TraceIndentGeneric.cs │ ├── TraceIdentBaseDto.cs │ └── LogParts.cs ├── BookServices │ ├── DropdownTuple.cs │ ├── BookListCombinedDto.cs │ ├── BookListDto.cs │ ├── Concrete │ │ └── ListBooksService.cs │ └── QueryObjects │ │ ├── BookListDtoSort.cs │ │ └── BookListDtoSelect.cs ├── OrderServices │ ├── OrderListDto.cs │ └── Concrete │ │ ├── PlaceOrderServiceWithVal.cs │ │ └── DisplayOrdersService.cs ├── CheckoutServices │ ├── CheckoutItemDto.cs │ └── Concrete │ │ ├── BasketCookie.cs │ │ └── CheckoutListService.cs ├── ServiceLayer.csproj ├── DatabaseServices │ ├── Concrete │ │ ├── BookInfoJson.cs │ │ └── SpecialBook.cs │ └── SetupHelpers.cs ├── BizRunners │ ├── RunnerWriteDbAsync.cs │ ├── RunnerWriteDbWithValidationAsync.cs │ ├── RunnerWriteDb.cs │ └── RunnerWriteDbWithValidation.cs ├── AppStart │ └── NetCoreDiSetupExtensions.cs └── DataKeyServices │ └── Concrete │ └── UserIdService.cs ├── BizDbAccess ├── BizDbAccess.csproj └── AppStart │ └── NetCoreDiSetupExtensions.cs ├── LICENSE ├── .vscode ├── tasks.json └── launch.json └── .gitattributes /BookApp/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /BookApp/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonPSmith/EfCoreinAction-SecondEdition/HEAD/BookApp/Startup.cs -------------------------------------------------------------------------------- /BookApp/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonPSmith/EfCoreinAction-SecondEdition/HEAD/BookApp/wwwroot/favicon.ico -------------------------------------------------------------------------------- /BookApp/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using BookApp 2 | @using BookApp.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Test/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "UnitTestConnection": "Server=(localdb)\\mssqllocaldb;Database=EfCoreInActionDb2-Test;Trusted_Connection=True;MultipleActiveResultSets=true" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /BookApp/Views/Admin/BookUpdated.cshtml: -------------------------------------------------------------------------------- 1 | @model string 2 | 3 |
You can see the SQL that EF Core produced to implement your change.
6 | 7 | @Html.ActionLink("All Books", "Index", "Home") 8 | 9 | -------------------------------------------------------------------------------- /BookApp/bundleconfig.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "outputFileName": "wwwroot/js/bundle.js", 4 | "inputFiles": [ 5 | "wwwroot/js/bookList.js", 6 | "wwwroot/js/loggingDisplay.js" 7 | ] 8 | } 9 | ] 10 | -------------------------------------------------------------------------------- /BookApp/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /BookApp/Views/Checkout/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model System.Collections.Immutable.ImmutableList
7 | The Book App uses a cookie to hold your basket of books you want to buy.
8 |
9 | This cookie also creates a random GUID which becomes your pseudo-UserId.
10 |
NOTE: This is a demo, so your order will NOT be delivered
11 | 12 | @Html.ActionLink("See all your orders", "Index", new { }, new { @class = "btn btn-primary" }) 13 |
12 | Request ID: @Model.RequestId
13 |
18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |
20 |21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |
26 | -------------------------------------------------------------------------------- /Test/Chapter02Listings/BookHashReview.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Jon P Smith, GitHub: JonPSmith, web: http://www.thereformedprogrammer.net/ 2 | // Licensed under MIT license. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using DataLayer.EfClasses; 7 | 8 | namespace Test.Chapter02Listings 9 | { 10 | public class BookHashReview 11 | { 12 | public int BookId { get; set; } 13 | public string Title { get; set; } 14 | public string Description { get; set; } 15 | public DateTime PublishedOn { get; set; } 16 | public string Publisher { get; set; } 17 | public decimal Price { get; set; } 18 | public string ImageUrl { get; set; } 19 | 20 | public bool SoftDeleted { get; set; } 21 | 22 | //----------------------------------------------- 23 | //relationships 24 | 25 | public HashSet