Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Could anybody help me about how to Insert server time when I insert data in DB(SQL Server). for example if i use stored procedure I would use GETDATE() but how to do it in LINQ?
thanx
Posted
Comments
Herman<T>.Instance 7-Feb-12 7:00am    
DateTime.Now ?

You can add this to your data context :
C#
public partial class YourDataContext
{
  public DateTime GetDate()
  {
    return ExecuteQuery<DateTime>("SELECT GETDATE()").First();
  }
}


extracted from here :
http://stackoverflow.com/questions/200617/how-do-i-use-sqls-getdate-and-dateadd-in-a-linq-to-sql-expression[^]

Also have a look at this one :
http://social.msdn.microsoft.com/forums/en-US/linqprojectgeneral/thread/9204a37f-0d55-4b74-8906-0aed10019d38/[^]

Hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900