Linq - How to construct this query without the 'join' keyword? -
i have following partial linq query:
var query = ri in routeinstance join rir in routeinstancerules on ri.routeinstanceid equals rir.routeinstanceid join rl in routinglocation on rir.routinglocationid equals rl.routinglocationid join rlh in routinglocationhistory on rl.routinglocationid equals rlh.routinglocationid rlh.routetakentime >= new system.datetime(2011,2,4) && rlh.routetakentime <= new system.datetime(2011,2,5) there 1:m relationship between routeinstance , routeinstancerules there 1:m relationship between routeinstancerules , routinglocation there 1:m relationship between routinglocation , routinglocationhistory
since these relationships enforced using fks , therefore known l2s, should able construct query without using 'join' keyword. but, stumped how it.
thanks.
you want routeinstances in end? if so:
var query = datacontext.routinglocationhistory .where(rlh => rlh.routetakentime >= new system.datetime(2011,2,4) && rlh.routetakentime <= new system.datetime(2011,2,5)) .select(rlh => rlh.routinglocation.routeinstancerule.routeinstance) .distinct();
Comments
Post a Comment