var query = from p in user.GetType().GetProperties()
select p.GetValue(user).ToString();
The call to ToString()
is required because you are wanting an enumerable of strings, not an enumerable of objects. However, this does run the risk of a Null Reference error in the case where a property value equals null
A safer alternative is this:
var query = user.GetType()
.GetProperties()
.Select(p => p.GetValue(user))
.Select(o => Object.ReferenceEquals(o, null)
? default(string)
: o.ToString()
);