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 "/" | |
@using BlazorAppPart4.Repositories | |
@using BlazorAppPart4.Model | |
@inject ICustomerRepository customerRepo | |
@rendermode RenderMode.InteractiveServer | |
<PageTitle>Home</PageTitle> |
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
namespace BlazorAppPart4 | |
{ | |
public class AppConfig | |
{ | |
public AppConfig() { | |
Database = new DbConfig(); | |
} | |
public DbConfig Database { get; set; } | |
} | |
public class DbConfig |
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 BlazorAppPart4; | |
using BlazorAppPart4.Components; | |
using BlazorAppPart4.Model; | |
using BlazorAppPart4.Repositories; | |
using Microsoft.EntityFrameworkCore; | |
var builder = WebApplication.CreateBuilder(args); | |
// Add services to the container. | |
builder.Services.AddRazorComponents() |
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
{ | |
"AppConfig": { | |
"Database": { | |
"ConnectionString": "mongodb://localhost:27017", | |
"DatabaseName": "northwind" | |
} | |
}, | |
"Logging": { | |
"LogLevel": { | |
"Default": "Information", |
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 BlazorAppPart4.Model; | |
using Microsoft.EntityFrameworkCore; | |
namespace BlazorAppPart4.Repositories | |
{ | |
public class CustomerRepository : ICustomerRepository | |
{ | |
private readonly AppDbContext _db; | |
public CustomerRepository(AppDbContext db) | |
{ |
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 BlazorAppPart4.Model; | |
namespace BlazorAppPart4.Repositories | |
{ | |
public interface ICustomerRepository | |
{ | |
Task<List<Customer>> GetAllAsync(); | |
} | |
} |
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 Microsoft.EntityFrameworkCore; | |
namespace BlazorAppPart4.Model | |
{ | |
public class AppDbContext: DbContext | |
{ | |
public DbSet<Customer> Customers { get; init; } | |
public AppDbContext(DbContextOptions options) | |
: base(options) | |
{ |
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 MongoDB.Bson; | |
using MongoDB.Bson.Serialization.Attributes; | |
using MongoDB.EntityFrameworkCore; | |
namespace BlazorAppPart4.Model | |
{ | |
[Collection("customers")] | |
public class Customer | |
{ | |
[BsonId] |
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
install-package MongoDb.EntityFrameworkCore |
NewerOlder