Sunny Dhiman

Sunny Dhiman

  • NA
  • 81
  • 6k

set record in tempdata

May 12 2021 10:27 AM
I have use this code set record in TempData .But Here CategoryId Multiple time for e.g 261 id 3 time but i want to add this id only one time like 261 one time
foreach (var customEntity in customEntityResult.Items)
{
var model = (BlogPostDataModel)customEntity.Model;
var blogPost = new BlogPostSummary();
blogPost.Title = customEntity.Title;
blogPost.ShortDescription = model.ShortDescription;
blogPost.ThumbnailImageAsset = images.GetOrDefault(model.ThumbnailImageAssetId);
blogPost.FullPath = customEntity.PageUrls.FirstOrDefault();
blogPost.PostDate = customEntity.CreateDate;
blogPost.CategoryId = model.CategoryIds.Distinct().SingleOrDefault();
blogPosts.Add(blogPost);
}
TempData["blogPostUrl"] = JsonConvert.SerializeObject(blogPosts);

Answers (1)