這些都是我的課:組對象共享相同的密鑰和扮演他們在另一個對象
class Schedule
{
Int32 Id {get; set;}
String CustomerName {get; set;}
DateTime SchedStartDate {get; set;}
DateTime SchedEndDate {get; set;}
List<Body> Body {get; set;}
}
class Body
{
Int32 Id {get; set;}
String ProductBarcode {get; set;}
Int32 ProductItemId {get; set;}
DateTime DtEvaluation {get; set;}
List<History> History {get; set;}
}
class History
{
Int32 ActionId { get; set; }
String Description { get; set; }
String Picture { get; set; }
String Observation { get; set; }
Int32 EvalItemId { get; set; }
Int32 EvalCriteriaId { get; set; }
}
我有一個Schedule
對象和字符串Body.ProductBarcode
重複Schedule.Body
名單上。此外,有時列表Body.History
是空的,有時不是。
Body.ProductBarcode
從應用程序的角度來看,重複是正確的,但是當我嘗試合併數據時,它給我帶來了一些麻煩,因爲我希望它將Schedule
對象投射到另一個類中(我覺得更容易同)工作:
class EmailSchedule
{
String Id { get; set; }
Int32 ProductId { get; set; }
DateTime DtEvaluation { get; set; }
List<EmailHistory> History { get; set; }
}
class EmailHistory
{
Int32 ActionId { get; set; }
String Description { get; set; }
String Picture { get; set; }
String Observation { get; set; }
String EvalItemId { get; set; }
Int32 EvalCriteriaId { get; set; }
}
請記住,在這一點上,我感興趣的唯一的事情就是Body.ProductBarcode
鍵,每一個它的Body.History
名單。 Schedules
的屬性已經安全無虞,其他Body
的屬性無用。
將被轉換成Schedule
對象
我的問題是一個JSON的This is an example,由於有反覆Body.ProductBarcode
我需要組,其中Body.ProductBarcode
比賽,這之後將所有Body.History
名單的出現相同的EmailSchedule.History
列表。
我試過使用LINQ,但由於我不熟悉它,因此無法使其工作。
當你說「組」和「帶」,你是什麼意思是什麼呢?如果它們與「ProductItemId」或「DtEvaluation」不同,如何分組? – NetMage
我編輯了這個問題。此時唯一重要的屬性是「Body.ProductBarcode」。其他屬性是無用的。 –
因此,在您的新EmailSchedule對象中,您不介意ProductId和DtEvaluation是否爲零或零? – NetMage