本文整理汇总了C#中IQueryable.ToDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# IQueryable.ToDictionary方法的具体用法?C# IQueryable.ToDictionary怎么用?C# IQueryable.ToDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQueryable
的用法示例。
在下文中一共展示了IQueryable.ToDictionary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendReminderMail
public void SendReminderMail(int activityId, IQueryable<User> senderList, EmailType emailType, string freeText = "")
{
var activity = _activityRepository.GetActivityById(activityId);
var toAddressToName = senderList.ToDictionary(teamMember => teamMember.Email, teamMember => teamMember.Name);
var text = NewEventText(activity, emailType, "");
SendMail(toAddressToName, _emailSettings.From, activity.OrganizingTeam.Name, text.Subject, text.Body);
}
示例2: sortMoviesBasedOnUserPreference
private static IEnumerable<Movie> sortMoviesBasedOnUserPreference(IQueryable<Movie> allMovies, UserMoviePreference userPreference)
{
var moviesById = allMovies.ToDictionary(m => m.Id);
var sortedMovies = new List<Movie>();
foreach (var id in userPreference.SortOrder)
{
if (!moviesById.ContainsKey(id)) continue;
sortedMovies.Add(moviesById[id]);
moviesById.Remove(id);
}
foreach (var remainingMovieId in moviesById.Keys.OrderBy(id => id))
{
sortedMovies.Add(moviesById[remainingMovieId]);
}
return sortedMovies;
}
示例3: FavoriteCollectionResponseMapping
public List<FavoriteInfoResponse> FavoriteCollectionResponseMapping(IQueryable<FavoriteEntity> source,
CoordinateInfo coordinateInfo)
{
if (source == null)
{
return new List<FavoriteInfoResponse>(0);
}
var linq = source;
var prolist = _promotionRepository.Get(new PromotionFilter
{
DataStatus = DataStatus.Normal,
});
var prodList = _productRepository.Get(null, new ProductFilter
{
DataStatus = DataStatus.Normal,
});
var linqPro = linq.Where(v => v.FavoriteSourceType == (int)SourceType.Promotion)
.Join(prolist, p => p.FavoriteSourceId,
f => f.Id,
(p, f) =>
new
{
Favor = p,
Pro = f
}
);
var linqProd = linq.Where(v => v.FavoriteSourceType == (int)SourceType.Product)
.Join(prodList, p => p.FavoriteSourceId,
f => f.Id,
(p, f) =>
new
{
Favor = p,
Prod = f
}
);
var itemRepoonse = ItemsInfoResponseMapping(linqProd.Select(v => v.Prod), linqPro.Select(v => v.Pro), coordinateInfo, false);
//sort
//itemRepoonse = itemRepoonse.OrderByDescending(v => v.CreatedDate);
var s = source.ToDictionary(v => String.Concat(v.FavoriteSourceId, "_", v.FavoriteSourceType), v => v);
var list = FavoriteInfoResponseMapping(itemRepoonse, s);
return list.OrderByDescending(v => v.CreatedDate).ToList();
}