public bool UpdateEx(T entity, List <string> lstColumns, string strWhere, List <SugarParameter> lstPars) { bool result; if (!string.IsNullOrEmpty(strWhere)) { if (lstColumns == null || lstColumns.Count <= 0) { result = this.Update(entity, strWhere, lstPars); } else { List <SugarParameter> list = new List <SugarParameter>(); List <string> list2 = new List <string>(); foreach (string current in lstColumns) { object attributeValueInModel = ClassHelper.GetAttributeValueInModel <object>(entity.GetType(), entity, current); string item = this._context.Db.Updateable <T>().UpdateBuilder.Builder.GetTranslationColumnName(current) + "=" + this._context.Db.Ado.SqlParameterKeyWord + current; list2.Add(item); list.Add(new SugarParameter(this._context.Db.Ado.SqlParameterKeyWord + current, attributeValueInModel)); } if (lstPars != null) { list.AddRange(lstPars); } string strSql = string.Format("update {0} set {1} where {2}", this._context.Db.Updateable <T>().UpdateBuilder.Builder.GetTranslationTableName(this._context.Db.Updateable <T>().UpdateBuilder.TableName), string.Join(",", list2), strWhere); result = this.Update(strSql, list.ToArray()); } } else { result = this.Update(entity, lstColumns, null); } return(result); }
public bool UpdateEx(T entity, List <string> lstColumns, Dictionary <string, object> lstWhere) { bool result; if (lstWhere != null && lstWhere.Count > 0) { List <SugarParameter> list = new List <SugarParameter>(); string text = null; if (lstWhere != null && lstWhere.Count > 0) { foreach (KeyValuePair <string, object> current in lstWhere) { bool flag = text == null; text += (flag ? " Where " : " AND "); string text2 = text; text = string.Concat(new string[] { text2, this._context.Db.Updateable <T>().UpdateBuilder.Builder.GetTranslationColumnName(current.Key), "=", this._context.Db.Ado.SqlParameterKeyWord, "w_", current.Key }); list.Add(new SugarParameter(this._context.Db.Ado.SqlParameterKeyWord + "w_" + current.Key, current.Value)); } } if (lstColumns == null || lstColumns.Count <= 0) { result = this.Update(entity, text, list); } else { List <string> list2 = new List <string>(); foreach (string current2 in lstColumns) { object attributeValueInModel = ClassHelper.GetAttributeValueInModel <object>(entity.GetType(), entity, current2); string item = this._context.Db.Updateable <T>().UpdateBuilder.Builder.GetTranslationColumnName(current2) + "=" + this._context.Db.Ado.SqlParameterKeyWord + current2; list2.Add(item); list.Add(new SugarParameter(this._context.Db.Ado.SqlParameterKeyWord + current2, attributeValueInModel)); } string strSql = string.Format("update {0} set {1} {2}", this._context.Db.Updateable <T>().UpdateBuilder.Builder.GetTranslationTableName(this._context.Db.Updateable <T>().UpdateBuilder.TableName), string.Join(",", list2), text); result = this.Update(strSql, list.ToArray()); } } else { result = this.Update(entity, lstColumns, null); } return(result); }
public Dictionary <string, object> CreateWhereDictWithModifyFields() { Type type = base.GetType(); this.InitPrimaryKeyList(); Dictionary <string, object> dictionary = new Dictionary <string, object>(); if (BaseEntity.m_lstKeys.ContainsKey(type) && BaseEntity.m_lstKeys[type].Count > 0) { foreach (string current in BaseEntity.m_lstKeys[type]) { dictionary.Add(current, this.m_lstModifyFields.ContainsKey(current) ? this.m_lstModifyFields[current] : ClassHelper.GetAttributeValueInModel <object>(base.GetType(), this, current)); } } return(dictionary); }