Created
January 4, 2015 15:47
-
-
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
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
[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