title: A recognition error occurred while using StartsWith in Nhibernate
body: <p>I am facing the following exception when executing a query with StartsWith over odata. I am using web API 2 to access SQL server database using Nhibernate</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"&gt;
  &lt;m:code/&gt;
  &lt;m:message xml:lang="en-US"&gt;An error has occurred.&lt;/m:message&gt;
  &lt;m:innererror&gt;
  &lt;m:message&gt;
   The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.
  &lt;/m:message&gt;
  &lt;m:type&gt;System.InvalidOperationException&lt;/m:type&gt;
  &lt;m:stacktrace/&gt;
  &lt;m:internalexception&gt;
  &lt;m:message&gt;
   A recognition error occurred. [.Where[CamConnect.Entities.Entities.TradeView](NHibernate.Linq.NhQueryable`1[CamConnect.Entities.Entities.TradeView], Quote(($it, ) =&gt; (Equal(Equal(Or(Equal($it.Cusip_Number, NULL), p1) ? NULLp3 : Convert($it.Cusip_Number.StartsWith(p2, )), p4), p5))), )]
  &lt;/m:message&gt;
  &lt;m:type&gt;NHibernate.Hql.Ast.ANTLR.QuerySyntaxException&lt;/m:type&gt;
  &lt;m:stacktrace&gt;
   at NHibernate.Hql.Ast.ANTLR.ErrorCounter.ThrowQueryException()
   at NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate()
   at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2 replacements, Boolean shallow, String collectionRole)
   at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)
   at NHibernate.Engine.Query.QueryExpressionPlan..ctor(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory)
   at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters)
   at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow)
   at NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression)
   at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)
   at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)
   at Remotion.Linq.QueryableBase`1.System.Collections.IEnumerable.GetEnumerator()
   at System.Web.Http.OData.Formatter.Serialization.ODataFeedSerializer.WriteFeed(Object graph, ODataWriter writer, ODataSerializerContext writeContext)
   at System.Web.Http.OData.Formatter.Serialization.ODataFeedSerializer.WriteObject(Object graph, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
   at System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.&lt;&gt;c__DisplayClassa.&lt;WriteToStreamAsync&gt;b__9()
   at System.Threading.Tasks.TaskHelpers.RunSynchronously(Action action, CancellationToken token)
  &lt;/m:stacktrace&gt;
  &lt;/m:internalexception&gt;
  &lt;/m:innererror&gt;
  &lt;/m:error&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>My Query:</strong></p>
  
  <pre><code>   var q = container.TradeView.Where(x =&gt; x.Cusip_Number.StartsWith("78"));
          var count = q.Count();
          Assert.IsTrue(count &gt; 0);
  </code></pre>