I’ve got a method that is being passed a vehicleID – I need to get all the SalesChannels that contain that vehicle. The SalesChannels have an IEnumerable of SalesChannelVehicle which have a property called VehicleID.
I tried this but it brings back all the SalesChannels, not just the one I know my Vehicle is in!
var queryable = Session.Linq<SalesChannel>();
queryable.Where(y => y.SalesChannelVehicle.Any(z => z.VehicleId == vehicleId));
Can anyone assist please? I’m using NHibernate, though I doubt that makes much difference to this issue.
I believe that you have to assign the returned value to something so have something like;
EDIT by KeithS: The difference between this and the OP is that the
resultsvariable now contains the IQueryable that includes the Where() method’s addition to the expression tree. Simply calling the methods onqueryabledoes not updatequeryable‘s expression tree in-place; you must assign the extended tree somewhere. If you wantedqueryableto include the Where() clause, you can simply assign to the same variable:You can also inline the Where() method call: