mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 10:37:55 +08:00
统一处理多对多表映射
This commit is contained in:
34
OpenAuth.Repository/RelevanceRepository.cs
Normal file
34
OpenAuth.Repository/RelevanceRepository.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
|
||||
namespace OpenAuth.Repository
|
||||
{
|
||||
public class RelevanceRepository :BaseRepository<Relevance>, IRelevanceRepository
|
||||
{
|
||||
|
||||
public void DeleteBy(string key,params int[] firstIds)
|
||||
{
|
||||
Delete(u => firstIds.Contains(u.FirstId) && u.Key == key);
|
||||
}
|
||||
|
||||
public void AddRelevance(string key, Dictionary<int, int> ids)
|
||||
{
|
||||
foreach (var roleid in ids)
|
||||
{
|
||||
Add(new Relevance
|
||||
{
|
||||
Key = key,
|
||||
FirstId = roleid.Key,
|
||||
SecondId = roleid.Value,
|
||||
OperateTime = DateTime.Now
|
||||
});
|
||||
}
|
||||
Save();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user