title: NotSupportedException: Could not convert constant 1 expression to string
body: <p>I'm manually building an Expression that uses IEnumerable.Where() to filter a DataServiceQuery from a WCF Data Service client-side proxy.</p>
  
  <pre><code>public class EntityIdentity
  {
      public EntityIdentity(long id);
      {
          this.Id = id;
      }
  
      private long Id {get; private set;}
  
      public override bool Equals(object obj)
      {
          return obj is EntityIdentity &amp;&amp; this.Id == (obj as EntityIdentity).Id;
      }
  
      public override string ToString()
      {
          return this.Id.ToString();
      }
  }
  
  public class Entity
  {
      public Entity()
      {
          this.Id = new EntityIdentity(0);
          this.Name = null; 
      }
  
      public EntityId Id { get; set; }
  
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>Given the classes above, I am creating an expression that is the equivalent to the following where <code>EntityIdentity targetId = new EntityIdentity(1)</code>.</p>
  
  <pre><code>container.Entities.Where(e =&gt; e.Id.Equals(targetId));
  </code></pre>
  
  <p>When I attempt to resolve this query, the LINQ-to-URI translator throws the following exception:</p>
  
  <pre><code>{System.NotSupportedException: Could not convert constant 1 expression to string.
     at System.Data.Services.Client.ExpressionWriter.VisitConstant(ConstantExpression c)
     at System.Data.Services.Client.ALinqExpressionVisitor.Visit(Expression exp)
     at System.Data.Services.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
     at System.Data.Services.Client.ExpressionWriter.Visit(Expression exp)
     at System.Data.Services.Client.ExpressionWriter.VisitOperand(Expression e, Nullable`1 parentType, Nullable`1 childDirection)
     at System.Data.Services.Client.ExpressionWriter.VisitBinary(BinaryExpression b)
     at System.Data.Services.Client.ALinqExpressionVisitor.Visit(Expression exp)
     at System.Data.Services.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
     at System.Data.Services.Client.ExpressionWriter.Visit(Expression exp)
     at System.Data.Services.Client.ExpressionWriter.VisitOperand(Expression e, Nullable`1 parentType, Nullable`1 childDirection)
     at System.Data.Services.Client.ExpressionWriter.VisitBinary(BinaryExpression b)
     at System.Data.Services.Client.ALinqExpressionVisitor.Visit(Expression exp)
     at System.Data.Services.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
     at System.Data.Services.Client.ExpressionWriter.Visit(Expression exp)
     at System.Data.Services.Client.ExpressionWriter.Translate(Expression e)
     at System.Data.Services.Client.ExpressionWriter.ExpressionToString(DataServiceContext context, Expression e, Boolean inPath, Version&amp; uriVersion)
     at System.Data.Services.Client.UriWriter.ExpressionToString(Expression expression, Boolean inPath)
     at System.Data.Services.Client.UriWriter.VisitQueryOptionExpression(FilterQueryOptionExpression fqoe)
     at System.Data.Services.Client.UriWriter.VisitQueryOptions(ResourceExpression re)
     at System.Data.Services.Client.UriWriter.VisitResourceSetExpression(ResourceSetExpression rse)
     at System.Data.Services.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
     at System.Data.Services.Client.UriWriter.Translate(DataServiceContext context, Boolean addTrailingParens, Expression e, Uri&amp; uri, Version&amp; version)
     at System.Data.Services.Client.DataServiceQueryProvider.Translate(Expression e)
     at System.Data.Services.Client.DataServiceQuery`1.Translate()
     at System.Data.Services.Client.DataServiceQuery`1.QueryComponents(ClientEdmModel model)
     at System.Data.Services.Client.DataServiceRequest.CreateExecuteResult(Object source, DataServiceContext context, AsyncCallback callback, Object state, String method)
     at System.Data.Services.Client.DataServiceRequest.BeginExecute(Object source, DataServiceContext context, AsyncCallback callback, Object state, String method)
     at System.Data.Services.Client.DataServiceQuery`1.BeginExecute(AsyncCallback callback, Object state)
     at System.Data.Services.Client.DataServiceQuery`1.BeginExecuteInternal(AsyncCallback callback, Object state)
     at System.Data.Services.Client.DataServiceQuery.BeginExecute(AsyncCallback callback, Object state)
     at ProAlign.ServerDataModule.Services.ModelSetQueryContext.&lt;&gt;c__DisplayClassa.&lt;Execute&gt;b__3()
     at System.Threading.Tasks.Task`1.InnerInvoke()
     at System.Threading.Tasks.Task.Execute()}
  </code></pre>
  
  <p>The aforementioned "constant 1 expression" refers to the value of the <code>targetId</code> variable.  What does this mean and what do I do about it?</p>