-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #3691
- Loading branch information
Showing
6 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
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
18 changes: 18 additions & 0 deletions
18
samples/core/Modeling/IndexesAndConstraints/DataAnnotations/IndexDescending.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace EFModeling.IndexesAndConstraints.DataAnnotations.IndexDescending; | ||
|
||
internal class MyContext : DbContext | ||
{ | ||
public DbSet<Blog> Blogs { get; set; } | ||
} | ||
|
||
#region IndexDescending | ||
[Index(nameof(Url), nameof(Rating), IsDescending = new bool[0])] | ||
public class Blog | ||
{ | ||
public int BlogId { get; set; } | ||
public string Url { get; set; } | ||
public int Rating { get; set; } | ||
} | ||
#endregion |
18 changes: 18 additions & 0 deletions
18
samples/core/Modeling/IndexesAndConstraints/DataAnnotations/IndexDescendingAscending.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace EFModeling.IndexesAndConstraints.DataAnnotations.IndexDescendingAscending; | ||
|
||
internal class MyContext : DbContext | ||
{ | ||
public DbSet<Blog> Blogs { get; set; } | ||
} | ||
|
||
#region IndexDescendingAscending | ||
[Index(nameof(Url), nameof(Rating), IsDescending = new[] { false, true })] | ||
public class Blog | ||
{ | ||
public int BlogId { get; set; } | ||
public string Url { get; set; } | ||
public int Rating { get; set; } | ||
} | ||
#endregion |
24 changes: 24 additions & 0 deletions
24
samples/core/Modeling/IndexesAndConstraints/FluentAPI/IndexDescending.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace EFModeling.IndexesAndConstraints.FluentAPI.IndexDescending; | ||
|
||
internal class MyContext : DbContext | ||
{ | ||
public DbSet<Blog> Blogs { get; set; } | ||
|
||
#region IndexDescending | ||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.Entity<Blog>() | ||
.HasIndex(b => new { b.Url, b.Rating }) | ||
.IsDescending(); | ||
} | ||
#endregion | ||
} | ||
|
||
public class Blog | ||
{ | ||
public int BlogId { get; set; } | ||
public string Url { get; set; } | ||
public int Rating { get; set; } | ||
} |
24 changes: 24 additions & 0 deletions
24
samples/core/Modeling/IndexesAndConstraints/FluentAPI/IndexDescendingAscending.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace EFModeling.IndexesAndConstraints.FluentAPI.IndexDescendingAscending; | ||
|
||
internal class MyContext : DbContext | ||
{ | ||
public DbSet<Blog> Blogs { get; set; } | ||
|
||
#region IndexDescendingAscending | ||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.Entity<Blog>() | ||
.HasIndex(b => new { b.Url, b.Rating }) | ||
.IsDescending(false, true); | ||
} | ||
#endregion | ||
} | ||
|
||
public class Blog | ||
{ | ||
public int BlogId { get; set; } | ||
public string Url { get; set; } | ||
public int Rating { 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