开发者

Converting LINQ statement from query to fluent c# syntax

Hey, I'm stuck in a converting a simple Linq statement from query syntax to fluent syntax in C#. I think that is possible, but I need a hint.

from property in target.GetType().GetProperties()
select new
{
   Name = property.Name,
   Value = property.G开发者_StackOverflow社区etValue(target, null)
};

to..

var props = target.GetType().GetProperties().Select(p=>p.Name.... )

What I need change after Select?


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


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

?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜