예제 #1
0
 private void AddColumnData(string tableName, FluentEntityProperty <EntityColumnAttribute> data)
 {
     if (!_selectedColumns.ContainsKey(tableName))
     {
         _selectedColumns.Add(tableName, new List <FluentEntityProperty <EntityColumnAttribute> >());
     }
     _selectedColumns[tableName].Add(data);
 }
예제 #2
0
        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);
        }
예제 #3
0
 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);
 }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
 public void AppendPropertyNamePlaceholder(FluentEntityProperty <EntityColumnAttribute> property)
 {
     _commandBuilder.Append($"@{property.Attribute.Name},");
 }
예제 #8
0
 private static bool IsRowVersion(FluentEntityProperty <EntityColumnAttribute> property)
 {
     return(property.Attribute.Name == RowVersion);
 }
예제 #9
0
 private static bool IsIdWithNullValue(FluentEntityProperty <EntityColumnAttribute> property, object value)
 {
     return(property.Property.Name.ToLower().Contains("id") && (value == null || IsIntegerNumber(value) && (long)value == 0L));
 }
예제 #10
0
 public static bool IsBoolean(FluentEntityProperty <EntityColumnAttribute> column)
 {
     return(column.Property.PropertyType == typeof(bool));
 }
예제 #11
0
 private static bool IsNotKey(FluentEntityProperty <EntityColumnAttribute> property)
 {
     return(!property.Attribute.IsKey);
 }