I've got linq which joins two lists by id and returns strongly typed List:
List<TestowaKlasaDlaLinq> linqlambda = ListDetailedData.Join(PlacesList, a => a.place.id, b => b.id, (a, b) =>
new TestowaKlasaDlaLinq()
{
Czas = a.startDate.TimeOfDay.ToString(),
Co = a.name,
Miasto = b.address.city,
Miejsce = a.organizer.designation
}).ToList();
For now everything works. Problem appeared when I tried to filter that list e.g.:
var onlyGdansk = linqlambda.Where(x => x.Miasto.Equals("Gdańsk")).Select(x => x).ToList();
That error came out:

How is this possible that strongly field of strongly typed List of type "TestowaKlasaDlaLinq" doesnt exist in that context?
I think, One of the x.Miasto value is null and that is the reason, it shows you this error.
var onlyGdansk = linqlambda.Where(tkdl => tkdl.Miasto!=null && tkdl.Miasto.Equals("Gdańsk")).Select(dl => dl).ToList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With