Skip to content

Instantly share code, notes, and snippets.

@foyzulkarim
Created January 4, 2015 15:47
Show Gist options
  • Save foyzulkarim/246af6bbfb9168851dd1 to your computer and use it in GitHub Desktop.
Save foyzulkarim/246af6bbfb9168851dd1 to your computer and use it in GitHub Desktop.
Create a resultant list from another two list by a condition. You can change " r2.Id == r.Id" this part for different logics
[TestMethod]
public void LinqTest()
{
RouteManager manager = new RouteManager();
ResponseModel responseModel = manager.Search(new RouteRequestModel());
List<Route> routes = responseModel.Data as List<Route>;
List<Route> permittedRoutes = new List<Route>
{
new Route() {Id = 2},
new Route() {Id = 9},
new Route() {Id = 10},
new Route() {Id = 11},
new Route() {Id = 19}
};
IEnumerable<Route> selectedRoutes = routes.Where(r => permittedRoutes.Any(r2 => r2.Id == r.Id)).ToList();
Assert.IsTrue(selectedRoutes.Any());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment