title: MIN and MAX value by string in Entity Framework
body: <p>I have database table. The ORM for it is:</p>
  
  <pre><code>public long Id { get; set; }
  public System.Guid AttrId { get; set; }
  public System.Guid ProdId { get; set; }
  public string Value { get; set; }
  
  public virtual Attributes Attributes { get; set; }
  public virtual Products Products { get; set; }
  </code></pre>
  
  <p>As you can see value is a string type. I'm trying to get min and max values by this field (some values represented as double). So here is my method for this:</p>
  
  <pre><code>public double[] GetMaxMinVals(Guid attrId)
  {
      double[] res = new double[2];
      using(entityContext = new SiteDBEntities())
      {
          res[0] = entityContext.ProductAttributes.Where(x=&gt;x.AttrId == attrId)
              .Min(x =&gt; Convert.ToDouble(x.Value));
          res[1] = entityContext.ProductAttributes.Where(x =&gt; x.AttrId == attrId)
              .Max(x =&gt; Convert.ToDouble(x.Value));
      }
  
      return res;
  }
  </code></pre>
  
  <p>But I getting exception:</p>
  
  <blockquote>
    <p>LINQ to Entities does not recognize the method 'Double ToDouble(System.String)' method, and this method cannot be translated into a store expression.</p>
  </blockquote>
  
  <p>So how can I search for a string value like a decimal?</p>