I would like to know how can I query an array of objects. For example I have an array object like CarList. So CarList would return me the object Car. Car has properties Model and Make. Now, I want to use linq to query the array CarList to get the Make of a Car whose Model is say "bmw". I tried the following
var carMake = from item in CarList where item .Model == "bmw" select s.Make;
Could not find an implementation of the query pattern for source type CarList
to the top of your file.
Car carList = ... var carMake = from item in carList where item.Model == "bmw" select item.Make;
or if you prefer the fluent syntax:
var carMake = carList .Where(item => item.Model == "bmw") .Select(item => item.Make);
Things to pay attention to:
selectclause instead if
s.Makeas in your code.