src/SSCMS.Core/Repositories/ChannelRepository.Select.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Datory;
using SSCMS.Core.Utils;
using SSCMS.Models;
namespace SSCMS.Core.Repositories
{
public partial class ChannelRepository
{
private string GetListKey(int siteId)
{
return CacheUtils.GetListKey(_repository.TableName, siteId);
}
private string GetEntityKey(int channelId)
{
return CacheUtils.GetEntityKey(_repository.TableName, channelId);
}
public async Task CacheAllAsync(Site site)
{
var cacheManager = await _repository.GetCacheManagerAsync();
if (!cacheManager.Exists(GetListKey(site.Id)) || !cacheManager.Exists(GetEntityKey(site.Id)))
{
var channels = await _repository.GetAllAsync(Q
.Where(nameof(Channel.SiteId), site.Id)
);
foreach (var channel in channels)
{
cacheManager.Put(GetEntityKey(channel.Id), channel);
}
var summaries = channels
.OrderBy(x => x.Taxis)
.ThenBy(x => x.Id)
.Select(x => new ChannelSummary
{
Id = x.Id,
ChannelName = x.ChannelName,
ParentId = x.ParentId,
ParentsPath = x.ParentsPath,
IndexName = x.IndexName,
ContentModelPluginId = x.ContentModelPluginId,
Taxis = x.Taxis,
AddDate = x.AddDate
}).ToList();
cacheManager.Put(GetListKey(site.Id), summaries);
}
}
public async Task<List<ChannelSummary>> GetSummariesAsync(int siteId)
{
return await _repository.GetAllAsync<ChannelSummary>(Q
.Select(nameof(Channel.Id), nameof(Channel.ChannelName), nameof(Channel.ParentId), nameof(Channel.IndexName), nameof(Channel.Taxis), nameof(Channel.AddDate))
后面还有 17 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
