mirror of https://github.com/abpframework/abp.git
committed by
GitHub
11 changed files with 21 additions and 94 deletions
@ -1,13 +0,0 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace Volo.Blogging.Posts |
|||
{ |
|||
public interface IPostTagRepository : IBasicRepository<PostTag> |
|||
{ |
|||
void DeleteOfPost(Guid id); |
|||
|
|||
Task<PostTag> FindByTagIdAndPostIdAsync(Guid postId, Guid tagId); |
|||
} |
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
using System; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Blogging.EntityFrameworkCore; |
|||
|
|||
namespace Volo.Blogging.Posts |
|||
{ |
|||
public class EfCorePostTagRepository : EfCoreRepository<IBloggingDbContext, PostTag>, IPostTagRepository |
|||
{ |
|||
public EfCorePostTagRepository(IDbContextProvider<IBloggingDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
} |
|||
|
|||
public void DeleteOfPost(Guid id) |
|||
{ |
|||
var recordsToDelete = DbSet.Where(pt=>pt.PostId == id); |
|||
DbSet.RemoveRange(recordsToDelete); |
|||
} |
|||
|
|||
public async Task<PostTag> FindByTagIdAndPostIdAsync(Guid postId, Guid tagId) |
|||
{ |
|||
return await DbSet.FirstOrDefaultAsync(pt=> pt.PostId == postId && pt.TagId == tagId); |
|||
} |
|||
} |
|||
} |
|||
@ -1,30 +0,0 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using MongoDB.Driver.Linq; |
|||
using Volo.Abp.Domain.Repositories.MongoDB; |
|||
using Volo.Abp.MongoDB; |
|||
using Volo.Blogging.MongoDB; |
|||
|
|||
namespace Volo.Blogging.Posts |
|||
{ |
|||
public class MongoPostTagRepository : MongoDbRepository<IBloggingMongoDbContext, PostTag>, IPostTagRepository |
|||
{ |
|||
public MongoPostTagRepository(IMongoDbContextProvider<IBloggingMongoDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
} |
|||
|
|||
public void DeleteOfPost(Guid id) |
|||
{ |
|||
var recordsToDelete = GetMongoQueryable().Where(pt => pt.PostId == id); |
|||
foreach (var record in recordsToDelete) |
|||
{ |
|||
Delete(record); |
|||
} |
|||
} |
|||
|
|||
public async Task<PostTag> FindByTagIdAndPostIdAsync(Guid postId, Guid tagId) |
|||
{ |
|||
return await GetMongoQueryable().FirstOrDefaultAsync(pt => pt.PostId == postId && pt.TagId == tagId); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue