我有此對象的數組:LINQ組由其中鍵是一個對象
public class WorkingOrderContract : BaseContract, IEquatable<WorkingOrderContract>
{
public string Id { get; set; }
public string Customer { get; set; }
public string CategoryId { get; set; }
public int ResourceId { get; set; }
public virtual ResourceContract Resource { get; set; }
public virtual CategoryContract Category { get; set; }
public WorkingOrderEnum EWorkingOrder { get; set; }
public TimeFlagEnum ETimeFlag { get; set; }
public bool Equals(WorkingOrderContract other)
{
return this.Id == other.Id;
}
}
通過JSON文件dinamically加載。
我使用此代碼組通過,但它不工作
var woListGrupped = this._workingOrderList.GroupBy(wo => wo.Category,
wo => wo,
(k, g) => new OdlByCategoryContract(k, g.ToList())
).ToList();
我該怎麼做呢?
「它不工作」是什麼意思?你會得到什麼結果?你期望什麼? – HimBromBeere