/// <summary> /// Constructor used by entity type aware formatters. /// </summary> protected SqlParameterFormatter(SqlParameterElementType elementType, string parameterValue, Type entityType, EntityMapping entityMappingOverride) { this.ElementType = elementType; this.ParameterValue = parameterValue; this.EntityType = entityType; this.EntityMappingOverride = entityMappingOverride; }
internal SqlStatementFormatter(EntityDescriptor mainEntityDescriptor, EntityMapping mainEntityMapping, ISqlBuilder mainEntitySqlBuilder) { this.MainEntityType = mainEntityDescriptor.EntityType; this.MainEntityDescriptor = mainEntityDescriptor; this.MainEntitySqlBuilder = mainEntitySqlBuilder; this.MainEntityMapping = mainEntityMapping; }
/// <summary> /// Default constructor. /// </summary> internal PropertyMapping(EntityMapping entityMapping, int order, PropertyDescriptor descriptor) { _order = order; _options = PropertyMappingOptions.None; _databaseColumnName = descriptor.Name; this.EntityMapping = entityMapping; this.Descriptor = descriptor; }
public SqLiteBuilder(EntityDescriptor entityDescriptor, EntityMapping entityMapping) : base(entityDescriptor, entityMapping, SqlDialect.SqLite) { if (this.KeyProperties.Length > 1) { throw new NotSupportedException($"Entity <{entityMapping.EntityType.Name}> has more than one primary keys. This is not supported by SqLite."); } }
/// <summary> /// Default constructor. /// </summary> public PropertyMapping(EntityMapping entityMapping, int order, PropertyMappingOptions options, PropertyDescriptor descriptor, string databaseColumn = null) { _order = order; _entityMapping = entityMapping; _options = options; _databaseColumnName = databaseColumn??descriptor.Name; this.Descriptor = descriptor; }
/// <summary> /// Default constructor. /// </summary> /// <param name="mainEntityDescriptor">Main entity descriptor</param> /// <param name="mainEntityMapping">Main entity mappings</param> /// <param name="mainEntitySqlBuilder">SQL mapper for the main entity</param> /// <param name="forceColumnAsTableColumnResolution">If true, the format identifier 'C' will be treated as 'TC' </param> internal SqlStatementFormatter(EntityDescriptor mainEntityDescriptor, EntityMapping mainEntityMapping, ISqlBuilder mainEntitySqlBuilder, bool forceColumnAsTableColumnResolution) { _forceColumnAsTableColumnResolution = forceColumnAsTableColumnResolution; this.MainEntityType = mainEntityDescriptor.EntityType; this.MainEntityDescriptor = mainEntityDescriptor; this.MainEntitySqlBuilder = mainEntitySqlBuilder; this.MainEntityMapping = mainEntityMapping; }
public SqLiteBuilder(EntityMapping entityMapping) : base(entityMapping, false, string.Empty) { if (this.KeyProperties.Length > 1) { throw new NotSupportedException($"Entity <{entityMapping.EntityType.Name}> has more than one primary keys. This is not supported by SqLite."); } }
/// <summary> /// Default constructor. /// </summary> public RelationshipEntityInstanceBuilderIdentity(EntityMapping entityMapping, object entity) { _keyPropertyValues = entityMapping.PropertyMappings.Values.Where(propMapping => propMapping.IsPrimaryKey).Select( propMapping => { var propDescriptor = propMapping.Descriptor; var propValue = propDescriptor.GetValue(entity); // assumes that all values for the entity keys provide proper hash keys // 'rotating hash' is fast due to the use of bit operation, provides a good distribution and doesn't cause overflows // http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx _hashCode = (_hashCode << 4) ^ (_hashCode >> 28) ^ (propValue?.GetHashCode() ?? 0); return propValue; }).ToArray(); }
protected GenericStatementSqlBuilder( EntityMapping entityMapping, bool usesTableSchema, string tableStartDelimiter, string tableEndDelimiter, string columnStartDelimiter, string columnEndDelimiter ) { this.EntityMapping = entityMapping; this.UsesSchemaForTableNames = usesTableSchema; this.TableStartDelimiter = tableStartDelimiter; this.TableEndDelimiter = tableEndDelimiter; this.ColumnStartDelimiter = columnStartDelimiter; this.ColumnEndDelimiter = columnEndDelimiter; this.SelectProperties = this.EntityMapping.PropertyMappings.Select(propMapping => propMapping.Value).ToArray(); this.KeyProperties = this.EntityMapping.PropertyMappings.Where(propMapping => propMapping.Value.IsKey).Select(propMapping => propMapping.Value).ToArray(); this.DatabaseGeneratedProperties = this.SelectProperties.Where(propInfo => propInfo.IsDatabaseGenerated).ToArray(); this.KeyDatabaseGeneratedProperties = this.KeyProperties.Intersect(this.DatabaseGeneratedProperties).ToArray(); this.UpdateProperties = this.SelectProperties.Except(this.KeyProperties).Where(propInfo => !propInfo.IsExcludedFromUpdates).ToArray(); this.InsertProperties = this.SelectProperties.Except(this.DatabaseGeneratedProperties).ToArray(); }
public PostgreSqlBuilder(EntityDescriptor entityDescriptor, EntityMapping entityMapping) : base(entityDescriptor, entityMapping, SqlDialect.PostgreSql) { }
public PostgreSqlBuilder(EntityMapping entityMapping) : base(entityMapping, true, string.Empty) { }
internal PropertyMapping Clone(EntityMapping newEntityMapping) { var clonedPropertyMapping = new PropertyMapping(newEntityMapping, this._order, this.Descriptor); clonedPropertyMapping._options = this._options; clonedPropertyMapping._databaseColumnName = this._databaseColumnName; if (this._relationshipPropertyNames != null) { clonedPropertyMapping._relationshipPropertyNames = new string[this._relationshipPropertyNames.Length]; Array.Copy( this._relationshipPropertyNames, clonedPropertyMapping._relationshipPropertyNames, this._relationshipPropertyNames.Length); } return clonedPropertyMapping; }
/// <summary> /// Default constructor. /// </summary> /// <remarks> /// http://www.postgresql.org/docs/8.0/static/sql-syntax.html#SQL-SYNTAX-IDENTIFIERS /// </remarks> public PostgreSqlBuilder(EntityMapping entityMapping) : base(entityMapping, true, string.Empty) { // decided not to use the standard delimiter (double quotes) due to problems when using nameof(columnName) without the delimiter in various clauses }
protected GenericStatementSqlBuilder(EntityMapping entityMapping, bool usesTableSchema, string tableAndColumnDelimiter) :this(entityMapping,usesTableSchema,tableAndColumnDelimiter,tableAndColumnDelimiter,tableAndColumnDelimiter,tableAndColumnDelimiter) { }
/// <summary> /// If overridden, returns the sql builder associated with the optional entity descriptor and entity mapping. /// Note: Any or all the parameters can be <c>NULL</c> /// </summary> protected virtual ISqlBuilder GetSqlBuilder(EntityDescriptor entityDescriptor, EntityMapping entityMapping) { return null; }
public MySqlBuilder(EntityMapping entityMapping) : base(entityMapping, false, "`") { }
public MsSqlBuilder(EntityMapping entityMapping) : base(entityMapping, true, "[", "]", "[", "]") { }
/// <summary> /// Constructor used when the entity type is set to the query's main one. /// </summary> public SqlParameterFormatter(SqlParameterElementType elementType, string parameterValue, EntityMapping entityMappingOverride) : this(elementType, parameterValue, null, entityMappingOverride) { }