0

我有以下包含评论的课程:

   public class Review
    {
        public string PartitionKey { get; set; }
        public string RowKey { get; set; }
    }

    IEnumerable<Review> review = // Filled with about 1000 reviews

我还有一个包含主题的课程:

    public class Topics
    {
        public string PartitionKey { get; set; }
        public string RowKey { get; set; }
        public string Topic { get; set; }
    }

    IEnumerable<Topic> topic = // Filled with about 300 topics

Review RowKey的前六个字符与 Topics 中的 RowKey 相同。在这两种情况下,分区键都是空字符串且未使用。

我在评论类中有大约 1000 条记录,在主题类中有 300 条记录。

有没有一种好方法可以使用 LINQ 结合 Review 和 Topics 来填充下面的新类:

 public class ReviewGrid
    {
        public string PartitionKey { get; set; }  // PartitionKey from Review
        public string RowKey { get; set; }  // RowKey from Review
        public string Topic { get; set; }   // This would be the Topic from Topics
    }

如果我使用 LINQ 执行此操作,是否需要很长时间才能创建?有没有办法让它更快地创建?

4

3 回答 3

1

我认为您正在寻找加入 PartitionKey

var reviewGrids = (from r in review
                   join t in topic on r.RowKey.Substring(0, 6) equals t.RowKey
                   select new ReviewGrid
                   {
                     r.PartitionKey,  
                     r.RoWKey,
                     t.Topic,
                   }).ToList();
于 2012-07-23T18:37:54.560 回答
0

你试过这个吗?

IEnumerable<ReviewGrid> rivewGrid = (from r in review
                                    join t in topic on r.PartitionKey equals t.PartitionKey
                                    select new ReviewGrid {
                                       PartitionKey = r.PartitionKey,
                                       RowKey = r.RowKey,
                                       Topic  = t.Topic
                                    })AsEnumerable<ReviewGrid>();
于 2012-07-23T18:41:41.763 回答
0
var reviewGrid = r.Join(t,
                x => x.PartitionKey + x.RowKey.Substring(6),
                y => y.PartitionKey + x.RowKey,
                (x,y)=>new { x.RowKey,x.PartitionKey,y.Topic  } );
于 2012-07-23T18:41:50.320 回答