Использование лямбда-выражения:
var users = xdoc.Root.Elements( "response" )
.Where( x => !string.IsNullOrEmpty( x.Element( "id" ).Value ) )
.Select( x => new User
{
Id = x.Element( "id" ).Value,
Name = x.Element( "full-name" ).Value,
Email = x.Descendants( "email-address" )
.Where( y => y.Element( "type" ).Value == "primary" )
.First().Element( "address" ).Value,
JobTitle = x.Element( "job-title" ).Value,
NetworkId = x.Element( "network-id" ).Value,
Type = x.Element( "type" ).Value,
} );
Выражение запроса мало чем отличается:
var users = from response in xdoc.Descendants( "response" )
where response.Element( "id" ) != null
select new User
{
Id = response.Element( "id" ).Value,
Name = response.Element( "full-name" ).Value,
Email = response.Descendants( "email-address" )
.Where( x => x.Element( "type" ).Value == "primary" )
.First().Element( "address" ).Value,
JobTitle = response.Element( "job-title" ).Value,
NetworkId = response.Element( "network-id" ).Value,
Type = response.Element( "type" ).Value
};