Posted On July 6, 2010

Getdate() with LINQ or Entity / LINQ veya Entity ile Getdate() nasil cekilir?

dearly 0 comments
Yazilimcinin Gunlugu >> Uncategorized >> Getdate() with LINQ or Entity / LINQ veya Entity ile Getdate() nasil cekilir?

EN:
Sometimes we need to use getdate() function instead of DateTime.Now. Because with getdate() we can get current date with correct format.

To be able to use Getdate() function from LINQ query you should create a view in SQL server.

Just Copy the query in the View and save as "GetDBdate".

SELECT     GETDATE() AS DBDate

Now you should update your Entity or DBML (add the view).
and write a LINQ query like below:

Convert.ToDateTime(db.GetDbDate.First().DBDate) 

TR:
Eğer LINQ/Entity sorgularında getdate() fonksiyonunu kullanmamız gerekiyorsa db de yeni bir view yaratmanız yeterli olacaktır :
Yeni bir view yaratın, Aşağıdakı query'i kopyalayın ve "GetDBDate"
 ismiyle kaydedin

 SELECT     GETDATE() AS DBDate

Şimdi Entity veya DBML inizi güncelleyin, yeni view i  de ekleyin

ve aşağıdaki gibi bir LINQ sorgusu yazın:

Convert.ToDateTime(db.GetDbDate.First().DBDate) 
 
 

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

x64 kurulu makinede is not a valid Win32 application hatasi

Merhaba, Buyuk bir heyecanla makineme Windows 7 64 bit yukledim. Visual Studio vs programlarini kurduktan sonra…

VS2005 AspNet web projelerini debug etmiyor

Merhaba, Geçenlerde eski projelerden birine bakmam gerekti. VS2005 ile yazılmıştı ve ufak bir düzeltme gerekiyordu.…

Powershell komutu ile bir klasörü sıkıştırıp yedeğini almak

##Oncelikle Backup'ini alacagimiz uygulamanin pathini yaziyoruz $kaynakPath="\\cronus\e$\IIS_APP\ironiccolakoglu" ##Dosya Adini olusturuyoruz $tarih=Get-Date $dosyaAdi= $tarih.Year.ToString()+$tarih.Month.ToString()+$tarih.Day.ToString()+"_"+$tarih.Hour.ToString()+$tarih.Minute.ToString()+".zip" ##Yedeklerin gonderilecegi…