问题描述
有人可以帮助我有关在DB(SQL Server)中插入数据时如何插入服务器时间的问题.例如,如果我使用存储过程,我将使用GETDATE(),但是如何在LINQ中使用它呢?
thanx
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
推荐答案
public partial class YourDataContext
{
public DateTime GetDate()
{
return ExecuteQuery<DateTime>("SELECT GETDATE()").First();
}
}
从这里提取:
http://stackoverflow.com/questions/200617/how-do-i-use-sqls-getdate-and-dateadd-in-a-linq-to-sql-expression [ ^ ]
也看看这一个:
http://social.msdn.microsoft.com /forums/zh-CN/linqprojectgeneral/thread/9204a37f-0d55-4b74-8906-0aed10019d38/ [ ^ ]
希望对您有所帮助.
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.
这篇关于使用linq插入服务器的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!