我目前有以下Linq查询(与Microsoft Dynamics CRM 2011相关)
var ContactDetails = Xrm.ContactSet
.Join(Xrm.AccountSet, c => c.ParentCustomerId, a => a.ParentAccountId, (c, a) => new { c.Telephone1, c.Telephone2, c.Telephone3, c.MobilePhone, c.FullName, a.Name })
.Where(c => (c.MobilePhone.Equals(CallerCli)) || (c.Telephone1.Equals(CallerCli)) ||
(c.Telephone2.Equals(CallerCli)) || (c.Telephone3.Equals(CallerCli)));
int Count = 0;
foreach (var c in ContactDetails)
{
Count++;
}
但是,在运行foreach时,我在第一个循环中得到以下异常:
The type arguments for method 'System.Linq.Enumerable.Join<TOuter,TInner,TKey,TResult>(System.Collections.Generic.IEnumerable<TOuter>, System.Collections.Generic.IEnumerable<TInner>, System.Func<TOuter,TKey>, System.Func<TInner,TKey>, System.Func<TOuter,TInner,TResult>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
只有在将.Join
添加到LINQ查询中时才会发生这种情况,但是搜索SO时我看不到任何类似的内容(如果我遗漏了某些内容,请道歉)。