I have a scenario where i have to use .Select with where in LINQ. Below is my query.
List<DTFlight> testList = _ctrFlightList.Select(i => new DTFlight() { AirLineName = i.AirLineName,ArrivalDate = i.ArrivalDate }).ToList();
I want ti use where(add condition) to this query.
Please Help... Thanks.
I suggest you this use of Where :
List<DTFlight> testList = _ctrFlightList.
Where(ctrFlight => ctrFlight.Property > 0).
Select(i => new DTFlight() { AirLineName = i.AirLineName, ArrivalDate = i.ArrivalDate }).ToList();
Where returns a IEnumerable, so you can apply your Select on it.