public override object VisitEFieldStringValue(DatabaseEditorExpressionParser.EFieldStringValueContext context) { var name = context.ID().GetText(); if (name == null || !definition.TableColumns.TryGetValue(name, out var column)) { return("(unknown)"); } var cell = entity?.GetCell(name); if (cell is DatabaseField <long> lField) { return(parameterFactory.Factory(column.ValueType).ToString(lField.Current.Value, new ToStringOptions() { WithNumber = false })); } if (cell is DatabaseField <float> fField) { return(fField.Current.ToString()); } if (cell is DatabaseField <string> sField) { return(parameterFactory.FactoryString(column.ValueType).ToString(sField.Current.Value ?? "", new ToStringOptions() { WithNumber = false })); } return(""); }
public EntityKey(DatabaseEntity entity, DatabaseTableDefinitionJson table) { fields = table.PrimaryKey !.Select(key => entity.GetCell(key) !).ToList(); hash = 0; foreach (var field in fields) { hash = HashCode.Combine(hash, field.GetHashCode()); } }
public static string FillTemplate(this DatabaseEntity entity, string template) { int indexOf = 0; indexOf = template.IndexOf("{", indexOf, StringComparison.Ordinal); while (indexOf != -1) { var columnName = template.Substring(indexOf + 1, template.IndexOf("}", indexOf, StringComparison.Ordinal) - indexOf - 1); template = template.Replace("{" + columnName + "}", entity.GetCell(columnName) !.ToString()); indexOf = template.IndexOf("{", indexOf + 1, StringComparison.Ordinal); } return(template); }
public override object VisitEFieldValue(DatabaseEditorExpressionParser.EFieldValueContext context) { var name = context.ID().GetText(); var cell = entity?.GetCell(name); if (cell is DatabaseField <long> lField) { return(lField.Current.Value); } if (cell is DatabaseField <float> fField) { return(fField.Current.Value); } return(0L); }