Exemplo n.º 1
0
        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("");
        }
Exemplo n.º 2
0
 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());
     }
 }
Exemplo n.º 3
0
    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);
    }
Exemplo n.º 4
0
        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);
        }