SORU
4 AĞUSTOS 2009, Salı


Seri int string

nasıl bir dizeye döküm int? Aşağıdaki hiç biri işe yaramadı

from s in ctx.Services
    where s.Code.ToString().StartsWith("1")
    select s

from s in ctx.Services
    where Convert.ToString(s.Code).StartsWith("1")
    select s

from s in ctx.Services
    where ((string)s.Code).ToString().StartsWith("1")
    select s

EDİT

Olsun hata:

LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression

CEVAP
20 Temmuz 2010, Salı


EF v4 SqlFunctions.StringConvert kullanabilirsiniz. Kodunuzu bu şekilde sona ereceğini bu yüzden:

from s in ctx.Services
where SqlFunctions.StringConvert((double)s.Code).StartsWith("1")
select s

EDİT

Rick onun yorum bahseder gibi, bir çift (ondalık muhtemelen de çalışır) int döküm nedeni int için bir aşırı yük yok.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Flohoo

    Flohoo

    12 EYLÜL 2009
  • max2sims2

    max2sims2

    19 Kasım 2008
  • PUSHER

    PUSHER

    11 HAZİRAN 2014