private void AddColumnData(string tableName, FluentEntityProperty <EntityColumnAttribute> data) { if (!_selectedColumns.ContainsKey(tableName)) { _selectedColumns.Add(tableName, new List <FluentEntityProperty <EntityColumnAttribute> >()); } _selectedColumns[tableName].Add(data); }
private static bool CanAppend(FluentEntityProperty <EntityColumnAttribute> property, object entity) { var id = 0L; if (property.Attribute.IsKey) { id = LongType.FromObject(property.Property.GetValue(entity) ?? 0L); } return(!property.Attribute.IsKey || id != 0L); }
private static object ConvertDbValue(object value, FluentEntityProperty <EntityColumnAttribute> column) { if (value == DBNull.Value) { value = null; } else if (FluentEntityAdoHelper.IsBoolean(column)) { value = Convert.ToBoolean(value); //we need to ensure that uint64 is properly converted to bool before we apply it to the model } return(value); }
public static object GetValue(FluentEntityProperty <EntityColumnAttribute> property, object entity) { var value = property.Property.GetValue(entity); if (IsRowVersion(property)) { value = DateTime.UtcNow; } if (IsIdWithNullValue(property, value)) { value = null; } return(value); }
protected void TableJoined <TJoined>(string tableSource, string tableDestination, FluentEntityProperty <EntityColumnRefAttribute> joinedProperty, object emptyObject) { // Create linking. var isBase = tableSource.Equals(_tableName); var propertyModel = isBase ? _referenceModel : _joinedTableObjects[tableSource]; joinedProperty?.Property.SetValue(propertyModel, emptyObject); // Check if all properties if (_allColumns) { AddAllColumns <TJoined>(tableDestination); } // Add data _tableNames.Add(tableDestination); _joinedTableObjects.Add(tableDestination, emptyObject); }
private IFluentEntityJoin <T> GenericJoin <TJoin1, TJoin2, TKey1, TKey2>( Expression <Func <T, TJoin2> > property, Expression <Func <TJoin1, TKey1> > onColumn1, Expression <Func <TJoin2, TKey2> > onColumn2, string joinCommand) where TJoin2 : new() { FluentEntityProperty <EntityColumnRefAttribute> joinedProperty = null; if (property != null) { joinedProperty = FluentEntityAdoHelper.GetColumnRefProperty(property); } var tableSource = FluentEntityAdoHelper.GetTableName(typeof(TJoin1)); var tableDestination = FluentEntityAdoHelper.GetTableName(typeof(TJoin2)); var propertySource = FluentEntityAdoHelper.ConcatTableColumn(tableSource, FluentEntityAdoHelper.GetColumnPropertyName(onColumn1)); var propertyDestination = FluentEntityAdoHelper.ConcatTableColumn(tableDestination, FluentEntityAdoHelper.GetColumnPropertyName(onColumn2)); _joinCommandBuilder.Append($" {joinCommand} {tableDestination} ON {propertySource} = {propertyDestination}"); TableJoined <TJoin2>(tableSource, tableDestination, joinedProperty, new TJoin2()); return(this); }
public void AppendPropertyNamePlaceholder(FluentEntityProperty <EntityColumnAttribute> property) { _commandBuilder.Append($"@{property.Attribute.Name},"); }
private static bool IsRowVersion(FluentEntityProperty <EntityColumnAttribute> property) { return(property.Attribute.Name == RowVersion); }
private static bool IsIdWithNullValue(FluentEntityProperty <EntityColumnAttribute> property, object value) { return(property.Property.Name.ToLower().Contains("id") && (value == null || IsIntegerNumber(value) && (long)value == 0L)); }
public static bool IsBoolean(FluentEntityProperty <EntityColumnAttribute> column) { return(column.Property.PropertyType == typeof(bool)); }
private static bool IsNotKey(FluentEntityProperty <EntityColumnAttribute> property) { return(!property.Attribute.IsKey); }