1、使用属性说明,但是不够灵活
[CanInsert = false, CanUpdate = false, ServerTime = DateTimeKind.Local)]
public System.DateTime WorkTime { get; set; }
2、使用SetRaw
var dbProvider = (this.dbContext._freeSql as BaseDbProvider);
var result = this.dbContext._freeSql.Update<InfoEntity>()
.Set(x => x.LastUpdateTime, DateTime.Now)
.SetRaw(string.Format("{0}={1}", "WorkTime", dbProvider.InternalCommonUtils.Now ))
.Where(x => x.Id = 10)
.ExecuteAffrows() > 0;
3、生成的SQL语句如下:
UPDATE [Info]
SET [LastUpdateTime] = @p_1,
WorkTime=getdate()
WHERE ([Id] = 10)