列表中的所有對象的值我有一個DTO是這樣的:選擇從字典
public class OrderDraft
{
public string FTPUser { get; set; }
public string AccountRef { get; set; }
public string SupplyFromWarehouse { get; set; }
public string UsePriceband { get; set; }
public string DocumentDate { get; set; }
public string DateRequested { get; set; }
public string DatePromised { get; set; }
public string CustomerDocumentNo { get; set; }
public List<Line> Lines { get; set; }
public Address DeliveryAddress { get; set; }
public string ShippingChargeCode { get; set; }
public decimal ShippingFee { get; set; }
}
我創建的上面的字典是這樣的:
Dictionary<string, OrderDraft> multiOrders
= new Dictionary<string, OrderDraft>();
現在我想回到從List<OrderDraft>
以上multiOrders
字典。要做到這一點,我試過如下:
return multiOrders.SelectMany(s => s.Value);
return multiOrders.SelectMany(s => s.Value).ToList<OrderDraft>;
我收到以下錯誤:
Error 2 The type arguments for method 'System.Linq.Enumerable.SelectMany(System.Collections.Generic.IEnumerable, System.Func>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
任何想法如何檢索所有值的List<T>
從Dictionary<String, T>
?
哇,這很簡單。現在我感到很蠢。謝謝:)我可以在10分鐘內接受這個答案。 – Latheesan
我還需要添加'使用System.Linq;'來使這個工作。 :) – user2441511