user3817564
user3817564

Reputation: 3

Convert to array in linq

var parentstl = from parentstyle in DBB.vParentStyles
select new {   parentstyle.name,
               parentstyle.description,
               parentstyle.price,
               parentstyle.categories
           };

I want parentstyle.categories to convert into int[] array.

How can I do that?

Upvotes: 0

Views: 76

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726987

You can use Select to make projections, like this:

var parentstl = from parentstyle in DBB.vParentStyles
select new {
    parentstyle.name,
    parentstyle.description,
    parentstyle.price,
    Categories = parentstyle.categories.ToArray()
 };

Upvotes: 2

Related Questions