private void SetUpdateItemByEntity(int i, T item, List <DbColumnInfo> updateItem) { foreach (var column in EntityInfo.Columns) { if (column.IsIgnore) { continue; } var columnInfo = new DbColumnInfo() { Value = column.PropertyInfo.GetValue(item, null), DbColumnName = GetDbColumnName(column.PropertyName), PropertyName = column.PropertyName, PropertyType = UtilMethods.GetUnderType(column.PropertyInfo), TableId = i }; if (columnInfo.PropertyType.IsEnum() && columnInfo.Value != null) { columnInfo.Value = Convert.ToInt64(columnInfo.Value); } if (column.IsJson) { columnInfo.IsJson = true; if (columnInfo.Value != null) { columnInfo.Value = this.Context.Utilities.SerializeObject(columnInfo.Value); } } if (column.IsArray) { columnInfo.IsArray = true; } var tranColumn = EntityInfo.Columns.FirstOrDefault(it => it.IsTranscoding && it.DbColumnName.Equals(column.DbColumnName, StringComparison.CurrentCultureIgnoreCase)); if (tranColumn != null && columnInfo.Value.HasValue()) { columnInfo.Value = UtilMethods.EncodeBase64(columnInfo.Value.ToString()); } updateItem.Add(columnInfo); } this.UpdateBuilder.DbColumnInfoList.AddRange(updateItem); }
private void SetInsertItemByEntity(int i, T item, List <DbColumnInfo> insertItem) { if (item == null) { return; } foreach (var column in EntityInfo.Columns) { if (column.IsIgnore || column.IsOnlyIgnoreInsert) { continue; } var isMapping = IsMappingColumns; var columnInfo = new DbColumnInfo() { Value = PropertyCallAdapterProvider <T> .GetInstance(column.PropertyName).InvokeGet(item), DbColumnName = column.DbColumnName, PropertyName = column.PropertyName, PropertyType = UtilMethods.GetUnderType(column.PropertyInfo), TableId = i }; if (column.DbColumnName == null) { column.DbColumnName = column.PropertyName; } if (isMapping) { columnInfo.DbColumnName = GetDbColumnName(column.PropertyName); } if (column.IsJson) { columnInfo.IsJson = true; } if (column.IsArray) { columnInfo.IsArray = true; } if (columnInfo.PropertyType.IsEnum() && columnInfo.Value != null) { if (this.Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true) { columnInfo.Value = columnInfo.Value.ToString(); columnInfo.PropertyType = UtilConstants.StringType; } else { columnInfo.Value = Convert.ToInt64(columnInfo.Value); } } if (column.IsJson && columnInfo.Value != null) { if (columnInfo.Value != null) { columnInfo.Value = this.Context.Utilities.SerializeObject(columnInfo.Value); } } //var tranColumn=EntityInfo.Columns.FirstOrDefault(it => it.IsTranscoding && it.DbColumnName.Equals(column.DbColumnName, StringComparison.CurrentCultureIgnoreCase)); if (column.IsTranscoding && columnInfo.Value.HasValue()) { columnInfo.Value = UtilMethods.EncodeBase64(columnInfo.Value.ToString()); } insertItem.Add(columnInfo); } }