Skip to content

Instantly share code, notes, and snippets.

... etc
<li class="nav-item px-3">
<NavLink class="nav-link" href="posts">
<span class="oi oi-list-rich" aria-hidden="true"></span> Posts
</NavLink>
</li>
... etc
// Pages/Post/Index.razor
@page "/posts"
@using Golb.Data
@using Golb.Services
@inject PostService service
@if (posts == null)
{
... etc
using Golb.Services;
public void ConfigureServices(IServiceCollection services)
{
...etc
services.AddTransient<PostService>();
}
// Services/PostService.cs
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Threading.Tasks;
using Golb.Data;
namespace Golb.Services
{
public interface IPostService
select Name from sys.Databases
use GolbDatabase
select * from information_schema.tables
select * from information_schema.columns where table_name = 'Posts'
/opt/mssql-tools/bin/sqlcmd -S localhost -U "sa" -P "yourPasswordHere" -I
docker exec -it sql_server bash
// Data/ApplicationDbContext.cs
public class ApplicationDbContext : IdentityDbContext
{
...etc
public DbSet<Post> Posts { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
// Data/Post.cs
using System;
namespace Golb.Data
{
public class Post
{
public int Id { get; set; }
public string Title { get; set; }
dotnet tool install --global dotnet-ef