C# 我可以重构我的linq select吗?

C# 我可以重构我的linq select吗?,c#,linq,C#,Linq,我有以下资料: var data1 = contentRepository.GetPk(pk); var data2 = from d in data1 select new Content.RowKeyTitle { RowKey = d.RowKey, Title = d.Title,

我有以下资料:

        var data1 = contentRepository.GetPk(pk);
        var data2 = from d in data1
                    select new Content.RowKeyTitle {
                        RowKey = d.RowKey,
                        Title = d.Title,
                        Notes = d.Notes
                    };
        return (data2);

有没有办法将data1和data2组合成一个表达式?

直接使用
GetPk
方法?那么您根本不需要
data1

var data = from d in contentRepository.GetPk(pk)
           select new Content.RowKeyTitle
           {
               RowKey = d.RowKey,
               Title = d.Title,
               Notes = d.Notes
           };
return data;

直接使用
GetPk
方法?那么您根本不需要
data1

var data = from d in contentRepository.GetPk(pk)
           select new Content.RowKeyTitle
           {
               RowKey = d.RowKey,
               Title = d.Title,
               Notes = d.Notes
           };
return data;

使用lambda表达式而不是理解语法

return contentRepository.GetPk(pk).Select(d => new Content.RowKeyTitle {
                    RowKey = d.RowKey,
                    Title = d.Title,
                    Notes = d.Notes
                });

使用lambda表达式而不是理解语法

return contentRepository.GetPk(pk).Select(d => new Content.RowKeyTitle {
                    RowKey = d.RowKey,
                    Title = d.Title,
                    Notes = d.Notes
                });