Reputation:
I have this query:
(from r in gServiceContext.CreateQuery("opportunity")
join c in gServiceContext.CreateQuery("contact") on ((EntityReference)r["new_contact"]).Id equals c["contactid"]
join n in gServiceContext.CreateQuery("annotation") on r["opportunityid"] equals ((EntityReference)n["objectid"]).Id into opp
from o in opp.DefaultIfEmpty().ToList()
where ((EntityReference)r["new_channelpartner"]).Id.Equals(lProfileProperty.PropertyValue) && ((OptionSetValue)r["new_leadstatus"]).Equals("100000002")
with the ToList()
I get this error:
The method 'GroupJoin' cannot follow the method 'Join' or is not supported. Try writing the query in terms of supported methods or call the 'AsEnumerable' or 'ToList' method before calling unsupported methods.
If I take the ToList off I get the same error. Is there away to fix this or am I doing it totally wrong?
Thanks!
Side Note: I'm using the DefaultIfEmpty because I need it to still pull down records even if the record its joined to is NULL.
Upvotes: 1
Views: 1840
Reputation: 327
You are not using your grouping, so this should work:
(from r in gServiceContext.CreateQuery("opportunity")
join c in gServiceContext.CreateQuery("contact") on ((EntityReference)r["new_contact"]).Id equals c["contactid"]
join n in gServiceContext.CreateQuery("annotation") on r["opportunityid"] equals ((EntityReference)n["objectid"]).Id
where ((EntityReference)r["new_channelpartner"]).Id.Equals(lProfileProperty.PropertyValue) && ((OptionSetValue)r["new_leadstatus"]).Equals("100000002")
Change
join c in gServiceContext.CreateQuery("contact")
to
join c in gServiceContext.CreateQuery("contact").DefaultIfEmpty()
Upvotes: 1