This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OrderHeader | |
{ | |
public string CustomerName { get; set; } | |
public DateTime DateCreated { get; set; } | |
public int TotalItems { get; set; } | |
public decimal TotalPrice { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SampleContext : DbContext | |
{ | |
public DbSet<Order> Orders { get; set; } | |
public DbSet<OrderItem> OrderItems { get; set; } | |
public DbSet<Customer> Customers { get; set; } | |
public DbQuery<OrderHeader> OrderHeaders { get; set; } | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnModelCreating(ModelBuilder modelBuilder) | |
{ | |
modelBuilder.Query<OrderHeader>().ToView("OrderHeaders"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SampleContext : DbContext | |
{ | |
public DbSet<Order> Orders { get; set; } | |
public DbSet<OrderItem> OrderItems { get; set; } | |
public DbSet<Customer> Customers { get; set; } | |
public DbQuery<OrderHeader> OrderHeaders { get; set; } | |
protected override void OnModelCreating(ModelBuilder modelBuilder) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BasePageModel : PageModel | |
{ | |
public bool Found { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomPageFilter : IAsyncPageFilter | |
{ | |
public async Task OnPageHandlerSelectionAsync(PageHandlerSelectedContext context) | |
{ | |
var instance = context.HandlerInstance; | |
if (instance.GetType().BaseType == typeof(BasePageModel)) | |
{ | |
((BasePageModel)instance).Found = true; | |
} | |
await Task.CompletedTask; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomPageFilterAttribute : ResultFilterAttribute | |
{ | |
public override async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next) | |
{ | |
var result = context.Result; | |
if (result is PageResult) | |
{ | |
var model = ((PageResult)result).Model; | |
if (model.GetType().BaseType == typeof(BasePageModel)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using WebApplication1 | |
@namespace WebApplication1.Areas.Customers.Pages | |
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@page | |
@model IndexModel | |
@{ | |
} | |
<h1>Customers Area</h1> |