码迷,mamicode.com
首页 > 其他好文 > 详细

新的转换列表方式

时间:2017-10-30 14:20:52      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:post   转换   tca   where   foreach   entity   lca   reac   each   

var categoriesEntities = new List<CategoryEntity>();
var allCategories = GetCategories();
var postCategoryMappings = _postCategoryMapping.Where(m => m.PostID == postID).ToList();

postCategoryMappings.ForEach(mapping =>
{
  var category = allCategories.Single(c => c.CategoryID == mapping.CategoryID);
  var categoryEntity = new CategoryEntity { CategoryID = mapping.CategoryID, CategoryName = category.CategoryName, CategorySlug = category.CategorySlug };
  categoriesEntities.Add(categoryEntity);
});

新的转换列表方式

标签:post   转换   tca   where   foreach   entity   lca   reac   each   

原文地址:http://www.cnblogs.com/opts/p/7753811.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!