DBテーブル「Memo」に対して必ず「WHERE isDeleted= 0」条件を加えます。
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Memo>().HasQueryFilter(s => s.isDeleted== 0 ); // WHERE isDeleted= 0 に限定する
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using EFCoreFilterApp1.Models;
namespace EFCoreFilterApp1.Data
{
public class MyContext : DbContext
{
public MyContext(DbContextOptions options) : base(options)
{
}
public DbSet<Memo> Memo { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Memo>().HasQueryFilter(s => s.MYID == 2 ); // WHERE MYID = 2 に限定する
}
}
}