将LINQ语句从查询转换为流畅的c#语法

Cus*_*dio 1 .net c# linq

嘿,我陷入了将查询语法中的简单Linq语句转换为C#中的流畅语法.我认为这是可能的,但我需要一个提示.

from property in target.GetType().GetProperties()
select new
{
   Name = property.Name,
   Value = property.GetValue(target, null)
};
Run Code Online (Sandbox Code Playgroud)

至..

var props = target.GetType().GetProperties().Select(p=>p.Name.... )
Run Code Online (Sandbox Code Playgroud)

我之后需要改变Select什么?

Dav*_*tka 11

var props = target
    .GetType()
    .GetProperties()
    .Select(p => new { 
        Name = p.Name, 
        Value = p.GetValue(target, null)
});
Run Code Online (Sandbox Code Playgroud)