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)
});
?
精彩评论