SORU
22 Temmuz 2012, Pazar


Belirtilen tip üyesi 'Tarih' Varlıklar bu SERİ desteklenmiyor Durum

Aşağıdaki ifadeleri uygularken bir durum var.

 DateTime result;
 if (!DateTime.TryParse(rule.data, out result))
     return jobdescriptions;
 if (result < new DateTime(1754, 1, 1)) // sql can't handle dates before 1-1-1753
     return jobdescriptions;
 return jobdescriptions.Where(j => j.JobDeadline.Date == Convert.ToDateTime(rule.data).Date );

Özel durum

The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.

Özel durum ne demek olduğunu biliyorum ama ondan kurtulmak için nasıl bilmiyorum. Herhangi bir yardım?

CEVAP
22 Temmuz 2012, Pazar


EntityFunctions TruncateTime yöntem SQL içine Date özelliği doğru çeviriler sağlamak için kullanabilirsiniz:

using System.Data.Objects; // you need this namespace for EntityFunctions

// ...

DateTime ruleData = Convert.ToDateTime(rule.data).Date;
return jobdescriptions
    .Where(j => EntityFunctions.TruncateTime(j.JobDeadline) == ruleData);

< / ^ br . Güncelleme:EntityFunctionsEF6, 8 ** Kullanımı önerilmiyor

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

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • How to Cook ?

    How to Cook

    31 Ocak 2007
  • Qmusic Romania

    Qmusic Roman

    8 Temmuz 2011
  • Santozz Yazz

    Santozz Yazz

    23 Mart 2014