CipherIS
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
});
}
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.