-
-
Save dialedin2014/c036a7d5c11409cfeb8d1b3291db9bc0 to your computer and use it in GitHub Desktop.
CurrentWidgetStatus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestClass] | |
public class Scratchpad | |
{ | |
[TestMethod] | |
public void CurrentWidgetStatus() | |
{ | |
List<Widget> widgetSubset = new List<Widget>(); | |
widgetSubset.Add(new Widget { Id = 1, Name = "Volvo" }); | |
widgetSubset.Add(new Widget { Id = 2, Name = "Mercedes" }); | |
widgetSubset.Add(new Widget { Id = 3, Name = "Ford" }); | |
List<WidgetStatus> widgetStatuses = new List<WidgetStatus>(); | |
widgetStatuses.Add( | |
new WidgetStatus | |
{ | |
Id = 1, | |
Status = "Late", | |
StatusDate = DateTime.Now.AddDays(-1) | |
}); | |
widgetStatuses.Add( | |
new WidgetStatus | |
{ | |
Id = 1, | |
Status = "OnTime", | |
StatusDate = DateTime.Now.AddDays(-2) | |
}); | |
widgetStatuses.Add( | |
new WidgetStatus | |
{ | |
Id = 2, | |
Status = "OnTime", | |
StatusDate = DateTime.Now.AddDays(-1) | |
}); | |
widgetStatuses.Add( | |
new WidgetStatus | |
{ | |
Id = 3, | |
Status = "Late", | |
StatusDate = DateTime.Now.AddDays(-5) | |
}); | |
widgetStatuses.Add( | |
new WidgetStatus | |
{ | |
Id = 3, | |
Status = "Abandoned", | |
StatusDate = DateTime.Now.AddDays(-2) | |
}); | |
widgetStatuses.Add( | |
new WidgetStatus | |
{ | |
Id = 4, | |
Status = "OnTime", | |
StatusDate = DateTime.Now.AddDays(-12) | |
}); | |
widgetStatuses.Add( | |
new WidgetStatus | |
{ | |
Id = 5, | |
Status = "OnTime", | |
StatusDate = DateTime.Now.AddDays(-9) | |
}); | |
//Assume that these are very large SQL datasets, | |
//what method syntax linq statement will get the latest | |
//status for each widget in the subset most efficiently? | |
} | |
private class Widget | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
} | |
private class WidgetStatus | |
{ | |
public int Id { get; set; } | |
public string Status { get; set; } | |
public DateTime StatusDate { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment