Determine if there are deltas/diffs Between Two Lists Of Same DataType

// Determine if there are unsaved changes
 var changedItems = from item1 in BoundJHAStaleNotifications
 from item2 in JHAStaleNotifications
 where item1.JHAStatus == item2.JHAStatus
 && item1.StaleUserType == item2.StaleUserType
 && ItemsAreDifferent(item1, item2)
 select item1;

 if (changedItems.Count() > 0)
 ((EHAP_MasterPage)Master).ErrorMessage = "There are unsaved changes on this tab. Please either Save or Cancel before proceeding.";

private bool ItemsAreDifferent(JHAStaleNotification item1, JHAStaleNotification item2)

 bool ItemsAreDifferent = (item1.JHAStatus == item2.JHAStatus &&
 item1.StaleUserType == item2.StaleUserType &&
 item1.EntityStateType == item2.EntityStateType &&
 item1.Frequency == item2.Frequency &&
 item1.SendNotification == item2.SendNotification &&
 item1.Threshold == item2.Threshold);

 return !ItemsAreDifferent;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s