本文整理汇总了C#中NHibernate.Mapping.List.Select方法的典型用法代码示例。如果您正苦于以下问题:C# List.Select方法的具体用法?C# List.Select怎么用?C# List.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Mapping.List
的用法示例。
在下文中一共展示了List.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckAvailability
private void CheckAvailability(List<SearchResultItem> results)
{
if (results.Count == 0)
{
return;
}
if (!cmsConfiguration.Security.AccessControlEnabled)
{
// If security is not enabled, all content is available
return;
}
// Create query
var principal = securityService.GetCurrentPrincipal();
var urls = results.Select(r => r.Link).ToArray();
var query = repository.AsQueryable<Page>(p => urls.Contains(p.PageUrl));
var pages = query
.SelectMany(c => c.AccessRules, (page, accessRule) => new
{
PageUrl = page.PageUrl,
AccessRule = accessRule
})
.ToList();
foreach (var pageUrl in pages.Select(p => p.PageUrl).Distinct())
{
var page = pages.First(p => p.PageUrl == pageUrl);
IList<IAccessRule> accessRules = pages.Where(p => p.PageUrl == pageUrl).Select(p => p.AccessRule).Cast<IAccessRule>().ToList();
var level = accessControlService.GetAccessLevel(accessRules, principal);
if (level < AccessLevel.Read)
{
results.Where(r => r.Link == page.PageUrl).ToList().ForEach(r => r.IsDenied = true);
}
}
results.ForEach(p =>
{
if (p.IsDenied)
{
p.Link = string.Empty;
p.FormattedUrl = LuceneGlobalization.SearchResults_Secured_LinkTitle;
p.Title = LuceneGlobalization.SearchResults_Secured_Title;
p.Snippet = LuceneGlobalization.SearchResults_Secured_Snippet;
}
});
}