Multiple Joins

Feb 18, 2010 at 11:37 PM

All,

  I was hoping a fresh set of eyes could see what I am doing wrong here. I have a working fetchxml expression that I can't seem to turn into linq.  I am trying to join account back to itself based on a relationship of client we have defined.

  My working fetchXml

<fetch mapping='logical'>
	<entity name='account'>
		<attribute name='accountnumber'/>
		<attribute name='name'/>
		<attribute name='accountid'/>
		<order attribute='name'/>
		<link-entity name='account' from='parentaccountid' to='accountid' alias='Client'>
			<attribute name='accountid'/>
			<attribute name='accountnumber'/>
			<attribute name='name'/>
			<link-entity name='customerrelationship' from='customerid' to='accountid'>
				<filter type='and'>
					<condition attribute='customerroleidname' operator='eq' value='Client'/>
				</filter>
			</link-entity>
		</link-entity>
	</entity>
</fetch>

I keep running into "Lambda parameter is not in scope" on line 71 of projectionBuilder.cs.

var result = from a1 in _provider.Linq<account>()
             join a2 in _provider.Linq<account>() on a1.parentaccountid.Value equals a2.accountid.Value
             join r in _provider.Linq<customerrelationship>() on a2.accountid.Value equals r.customerid.Value
             where r.customerroleid.name == "Client"
             select new{a1, a2};
_provider.Log = new XmlIndentingWriter(Console.Out);

  Any ideas would be appreciated!

Chris

Mar 11, 2010 at 1:37 AM

I'm wondering what you are planning to do with {a1, a2}.  Some more code might help so someone can gauge your intent.