private string MapType(PropertyInfo property, SqliteColumnAttribute columnData) { if (columnData.CustomBehaviour != null) { var customBehaviour = (CustomColumnBehaviour)Activator.CreateInstance(columnData.CustomBehaviour); return(customBehaviour.MapType(columnData, property)); } var columnType = property.PropertyType; if (columnType == typeof(int) || columnType == typeof(long) || columnType.IsEnum) { return("integer"); } if (columnType == typeof(bool)) { return("bit"); } if (columnType == typeof(string)) { return($"varchar({columnData.Size})"); } throw new NotSupportedException("Property type not supported"); }
private string ResolveValue(PropertyInfo property, object value, SqliteColumnAttribute columnData) { var processedValue = value; if (processedValue == null) { return($"NULL"); } if (columnData.CustomBehaviour != null) { var customBehaviour = (CustomColumnBehaviour)Activator.CreateInstance(columnData.CustomBehaviour); processedValue = customBehaviour.ResolveValue(columnData, property, processedValue); } if (value.GetType().IsEnum) { return(((int)processedValue).ToString()); } if (processedValue is string) { return($"'{EscapeString(processedValue.ToString())}'"); } if (processedValue is bool b) { return(b ? "1" : "0"); } return($"{processedValue}"); }
public abstract object ResolveValue(SqliteColumnAttribute columnData, PropertyInfo property, object value);
public abstract string MapType(SqliteColumnAttribute columnData, PropertyInfo property);