2014 m. sausio 9 d., ketvirtadienis

Entities and LIKE

Problema:
 
LINQ to Entities does not recognize the method 'Boolean Like(System.String, System.String)' method, and this method cannot be translated into a store expression.
 
   objs = From no In odbef.IKSA19_OrdNo_ProdCode
          Where Not no.IKSA19_Records.Any()
          Select no
          Distinct
 
   If tbOrderNo.Text.Trim <> "" Then
 
       objs = objs.Where(Function(x) Data.Linq.SqlClient.SqlMethods.Like(x.OrderNo, tbOrderNo.Text.Trim & "%"))
 
   End If
 
 
 
 
Sprendimas: naudoti contains
 
 
If tbOrderNo.Text.Trim <> "" Then
   objs = objs.Where(Function(x) x.OrderNo.Contains(tbOrderNo.Text.Trim))
End If
 
 
 

Komentarų nėra:

Rašyti komentarą