使用linq插入数据库所在服务器的时间

  partial class DataContext
    {
        public DateTime GetDate() { return ExecuteQuery<DateTime>("SELECT GETDATE()").First(); }

        /// <summary>
        /// 获取服务器时间
        /// </summary>
        /// <returns>时间</returns>
        [Function(Name = "GetDate", IsComposable = true)]
        public DateTime GetServerDate()
        {          
            MethodInfo mi = MethodBase.GetCurrentMethod() as MethodInfo;
            return (DateTime)this.ExecuteMethodCall(this, mi, new object[] { }).ReturnValue;
        }
    }

你可能感兴趣的:(LINQ)