title: Microsoft Dynamics 2011 N:N LINQ query with where clause containing Guid
body: <p>I have constructed a simple query to return a Users Team membership (N: N relationship).  This works fine for all users, however, when I add a where clause to restrict to a specific user it throws a fault exception (see stack trace below).</p>
  <p>Strangely this works fine with &quot;where Users.FullName.StartsWith(&quot;Alex&quot;)&quot;.  Does the Dynamics CRM SDK LINQ implementation not support Guides in where clauses?</p>
  <p>Any advice?</p>
  <p><strong>Example code</strong></p>
  <pre><code> using (var service = new OrganizationService(&quot;Xrm&quot;))
          {
              using (var xrm = new XrmServiceContext(service))
              {
                  var AlexUser = xrm.SystemUserSet.Where(p =&gt; p.FullName.StartsWith(&quot;Alex&quot;)).First();
                  var AlexID = AlexUser.Id;
  
                  var Test =
                          from Users in xrm.SystemUserSet
                          join TeamMemberships in xrm.TeamMembershipSet on Users.Id equals TeamMemberships.SystemUserId
                          join Teams in xrm.TeamSet on TeamMemberships.TeamId equals Teams.Id
                          where Users.Id == AlexID     // &lt;-- problematic where clause
                          orderby Users.FullName
                          select new
                          {
                              FullName = Users.FullName,
                              UserID = Users.Id,
                              TeamName = Teams.Name
                          };
  
                  var Test1 = Test.ToList();
              }
          }
  </code></pre>
  <p><strong>Stacktrace</strong>:</p>
  <blockquote>
  <p>Server stack trace:     at
  System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime
  operation, ProxyRpc&amp; rpc)    at
  System.ServiceModel.Channels.ServiceChannel.Call(String action,
  Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
  Object[] outs, TimeSpan timeout)    at
  System.ServiceModel.Channels.ServiceChannel.Call(String action,
  Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
  Object[] outs)    at
  System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
  methodCall, ProxyOperationRuntime operation)    at
  System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
  message)</p>
  <p>Exception rethrown at [0]:     at
  System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
  reqMsg, IMessage retMsg)    at
  System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp;
  msgData, Int32 type)    at
  Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest
  request)    at
  Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest
  request)    at
  Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Execute(OrganizationRequest
  request)    at
  Microsoft.Xrm.Client.Services.OrganizationService.&lt;&gt;c__DisplayClass19.b__18(IOrganizationService
  s)    at
  Microsoft.Xrm.Client.Services.OrganizationService.InnerOrganizationService.UsingService[TResult](Func<code>2 action)    at Microsoft.Xrm.Client.Services.OrganizationService.Execute(OrganizationRequest request)    at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.Execute(OrganizationRequest request)    at Microsoft.Xrm.Sdk.Linq.QueryProvider.RetrieveEntityCollection(OrganizationRequest request, NavigationSource source)    at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute(QueryExpression qe, Boolean throwIfSequenceIsEmpty, Boolean throwIfSequenceNotSingle, Projection projection, NavigationSource source, List</code>1 linkLookups,
  String&amp; pagingCookie, Boolean&amp; moreRecords)    at
  Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](QueryExpression
  qe, Boolean throwIfSequenceIsEmpty, Boolean throwIfSequenceNotSingle,
  Projection projection, NavigationSource source, List<code>1 linkLookups)    at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](Expression expression)    at Microsoft.Xrm.Sdk.Linq.QueryProvider.GetEnumerator[TElement](Expression expression)    at Microsoft.Xrm.Sdk.Linq.Query</code>1.GetEnumerator()    at
  System.Collections.Generic.List<code>1..ctor(IEnumerable</code>1 collection)<br />
  at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)    at
  aspirets.crm.test.Program.Main(String[] args) in
  C:\Users\a_marshall\documents\visual studio
  2010\Projects\aspirets.crm\aspirets.crm.test\Program.cs:line 37    at
  System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[]
  args)    at System.AppDomain.ExecuteAssembly(String assemblyFile,
  Evidence assemblySecurity, String[] args)    at
  Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br />
  at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br />
  at System.Threading.ExecutionContext.Run(ExecutionContext
  executionContext, ContextCallback callback, Object state, Boolean
  ignoreSyncCtx)    at
  System.Threading.ExecutionContext.Run(ExecutionContext
  executionContext, ContextCallback callback, Object state)    at
  System.Threading.ThreadHelper.ThreadStart()</p>
  </blockquote>