列表中的所有对象的值我有一个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