Link to home
Start Free TrialLog in
Avatar of CipherIS
CipherISFlag for United States of America

asked on

C# Linq Select From List

Below is some sample code.  I am trying to figure out how to use LINQ and select data from a List<> and return it to an object.  Code I am trying to resolve is located below the ?????.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test
{
    public class Product
    {
        public class ProductData
        {
            public string PropertyName { get; set; }
            public string Description { get; set; }
            public string Value01 { get; set; }
            public string Value02 { get; set; }
            public string Value03 { get; set; }
        }

        public class ProductRepo
        {
            public string PropertyName { get; set; }
            public string Description { get; set; }
        }

        List<ProductData> _productData = new List<ProductData>();

        public Product(List<ProductData> productData)
        {
            _productData = productData;

            //???????

            //var result = from x in _productData
            //             select new List<ProductRepo>()
            //             {
            //                 x.PropertyName,
            //                 x.Description
            //             };

            List<ProductRepo> productRepo = (from x in _productData
                                             select new List<ProductRepo>()
                                             {
                                                PropertyName = x.PropertyName,
                                                x.Description
                                             });
        }
    }
}

Open in new window

SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial