using Masuit.MyBlogs.Core.Infrastructure.Repository.Interface; using Masuit.MyBlogs.Core.Models.Entity; using Microsoft.EntityFrameworkCore; using System; using System.Linq.Expressions; using System.Threading.Tasks; namespace Masuit.MyBlogs.Core.Infrastructure.Repository { public partial class PostRepository : BaseRepository, IPostRepository { /// /// 添加实体 /// /// 需要添加的实体 /// 添加成功 public override Post AddEntity(Post t) { DataContext.Add(t); return t; } /// /// 获取第一条数据,优先从缓存读取 /// /// 查询条件 /// 实体 public override Task GetAsync(Expression> @where) { return DataContext.Post.Include(p => p.Category).Include(p => p.Seminar).FirstOrDefaultAsync(@where); } } }