この構造のオブジェクトがあります。
public class OrderItem
{
public string idProduct { get; set; }
public int quantity { get; set; }
public List<WarehouseItem> WarehouseInfo = new List<WarehouseItem>();
}
public class WarehouseItem
{
public string Name{ get; set; }
public string LocnCode{ get; set; }
}
私はすべてを取得しLocnCode
、それらによって区別する必要があるので、結果としてそれはであるはずですList<string>
。私はこれをやろうとしています
List<string> codes = itemList.Select(x => x.WarehouseInfo.Select(y => y.LocnCode)).Distinct();
しかし、このエラーがあります:
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<string>>' to 'System.Collections.Generic.List<string>'.
どうやってするの?