LINQ error with ToList
本文关键字:ToList with error LINQ | 更新日期: 2023-09-27 18:19:07
我有这样的查询:
(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")
与ToList()
,我得到这个错误:
方法'GroupJoin'不能跟随方法'Join',或者不是支持。尝试根据支持的方法或调用编写查询调用不支持的'AsEnumerable'或'ToList'方法方法。
如果我把tollist去掉,我得到同样的错误。有办法解决这个问题吗,还是我做得完全错了?
谢谢!
旁注:我使用DefaultIfEmpty,因为我需要它仍然下拉记录,即使它加入到的记录是NULL。
您没有使用分组,所以这应该可以工作:
(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")
改变join c in gServiceContext.CreateQuery("contact")
join c in gServiceContext.CreateQuery("contact").DefaultIfEmpty()