using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query.Internal;
public class BloggingContext : DbContext
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
public string DbPath { get; }
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
DbPath = System.IO.Path.Join(path, "blogging.db");
protected override void OnConfiguring(DbContextOptionsBuilder options) => options.UseSqlite($"Data Source={DbPath}");
protected override void OnModelCreating(ModelBuilder modelBuilder)
base.OnModelCreating(modelBuilder);
public int BlogId { get; set; }
public string Url { get; set; }
public string Title { get; set; }
public List<Post> Posts { get; set; } = new List<Post>();
public int PostId { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public int BlogId { get; set; }
public Blog Blog { get; set; }
public static void Main()
using var context = new BloggingContext();
var query1 = context.Set<Blog>().Where(b => b.Title.Length > len);
var query2 = (EntityQueryable<Blog>)query1;
Console.WriteLine(query2.DebugView.Query);
Console.WriteLine("\n\n");
Console.WriteLine(query2.DebugView.Query);