public virtual E SaveEntity(E entity) { IDbParameters dbParameters = DbParameters.Create(entity); if (entity.Id > 0) { this.Db.Execute(QueryTemplate.CreateUpdateQuery(), dbParameters); } else { entity = Db.ExecuteAndQuery <E>(QueryTemplate.CreateInsertQuery(), dbParameters); } return(entity); }
public virtual async Task <E> SaveEntityAsync(E entity) { IDbParameters dbParameters = DbParameters.Create(entity); if (entity.Id > 0) { await this.Db.ExecuteAsync(QueryTemplate.CreateUpdateQuery(), dbParameters); } else { entity = await Db.ExecuteAndQueryAsync <E>(QueryTemplate.CreateInsertQuery(), dbParameters); } return(entity); }
public override User SaveEntity(User entity) { IDbParameters dbParameters = DbParameters.Create(entity); IList <string> excludedColumns = null; if (String.IsNullOrEmpty(entity.PasswordData)) { excludedColumns = new List <string> { "PasswordData" }; } if (entity.Id > 0) { return(this.Db.ExecuteAndQuery <User>(QueryTemplate.CreateUpdateQuery(excludedColumns), dbParameters)); } else { return(Db.ExecuteAndQuery <User>(QueryTemplate.CreateInsertQuery(excludedColumns), dbParameters)); } }