/// <summary> /// Create a databasetype object that represents an expression type. (or as close as we can). /// </summary> /// <param name="exprType">The expression type.</param> public static DatabaseType ToDatabaseType(ExprType exprType) { if (exprType == null) { throw new ArgumentNullException("exprType"); } if (exprType.Type != DataType.Entity) { return(DataTypeHelper.ToDatabaseType(exprType.Type)); } if (exprType.EntityType == null) { return(DatabaseType.InlineRelationshipType); } var e = Entity.Get <EntityType>(exprType.EntityType.Id); if (e.Is <EnumType>()) { return(DatabaseType.ChoiceRelationshipType); } return(DatabaseType.InlineRelationshipType); }
public BuilderSettings() { RootContextType = new ExprType(DataType.None); DefaultDecimalPrecision = 3; DefaultCurrencyPlaces = 2; ScriptHost = ScriptHostType.Any; }
/// <summary> /// Get an ExprType that's appropriate for a given field. /// </summary> /// <param name="fieldEntity"></param> /// <returns></returns> public static ExprType FromFieldEntity(IEntity fieldEntity) { DataType dataType = FieldHelper.ConvertToDataType(fieldEntity); ExprType exprType = new ExprType(dataType); DecimalField decimalField = fieldEntity.As <DecimalField>(); if (decimalField != null) { exprType.DecimalPlaces = decimalField.DecimalPlaces; } return(exprType); }