-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathUseRowNumberDbContext.cs
More file actions
41 lines (36 loc) · 1.15 KB
/
UseRowNumberDbContext.cs
File metadata and controls
41 lines (36 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
namespace EntityFrameworkCore.UseRowNumberForPaging;
public class UseRowNumberDbContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
public DbSet<Author> Authors { get; set; }
public DbSet<Category> Categories { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(
@"Server=(localdb)\mssqllocaldb;Database=Blogging;Integrated Security=True", i => i.UseRowNumberForPaging());
}
}
public class Blog
{
public int BlogId { get; set; }
public string Url { get; set; }
public int Rating { get; set; }
public virtual Author Author { get; set; }
public virtual Category Category { get; set; }
}
public class Author
{
public int AuthorId { get; set; }
public string Name { get; set; }
public DateOnly ContributingSince { get; set; }
public virtual List<Blog> Blogs { get; set; }
}
public class Category
{
public int CategoryId { get; set; }
public string Name { get; set; }
public virtual List<Blog> Blogs { get; set; }
}