PoliDev
PoliDev

Reputation: 1458

How to group particular fields from the list using linq

I am getting lists from service. But In that particular service i need only 2 fields values alone. I write a select query, but it is not returning all lists.

var TranslResult = serviceResponse.Result.ToList();

selectedReasons = TranslResult.Select(x => new TranslationContentEntity
{
    ContentId= x.ContentId,
    ContentType= x.ContentType
});

But i am getting result of the following, enter image description here

Upvotes: 0

Views: 76

Answers (1)

wilovent
wilovent

Reputation: 1364

You can use anonymous class like this :

selectedReasons = TranslResult.Select(x => new 
{
     ContentId= x.ContentId,
     ContentType= x.ContentType
});

Upvotes: 2

Related Questions