Переглянути джерело

Made AutoEntityUnionGenerator type-safe

Kenric Nugteren 1 місяць тому
батько
коміт
d84bb41a7e
1 змінених файлів з 12 додано та 12 видалено
  1. 12 12
      InABox.Core/Objects/AutoEntity/AutoEntityUnionGenerator.cs

+ 12 - 12
InABox.Core/Objects/AutoEntity/AutoEntityUnionGenerator.cs

@@ -13,16 +13,16 @@ namespace InABox.Core
 
     public interface IAutoEntityUnionConstant
     {
-        object Value { get; }
+        object? Value { get; }
         IColumn Mapping { get; }
     }
 
     public class AutoEntityUnionConstant : IAutoEntityUnionConstant
     {
-        public object Value { get; private set; }
+        public object? Value { get; private set; }
         public IColumn Mapping { get; private set; }
 
-        public AutoEntityUnionConstant(object value, IColumn mapping)
+        public AutoEntityUnionConstant(object? value, IColumn mapping)
         {
             Value = value;
             Mapping = mapping;
@@ -78,15 +78,15 @@ namespace InABox.Core
             return this;
         }
         
-        public AutoEntityUnionTable<TInterface, TEntity> AddConstant<TType>(Expression<Func<TInterface, object?>> mapping, TType constant)
+        public AutoEntityUnionTable<TInterface, TEntity> AddConstant<TType>(Expression<Func<TInterface, TType>> mapping, TType constant)
         {
-            _constants.Add(new AutoEntityUnionConstant(constant, new Column<TInterface>(mapping)));
+            _constants.Add(new AutoEntityUnionConstant(constant, new Column<TInterface>(CoreUtils.GetFullPropertyName(mapping, "."))));
             return this;
         }
         
-        public AutoEntityUnionTable<TInterface, TEntity> AliasField<TType>(Expression<Func<TInterface, object?>> target, Expression<Func<TEntity, TType>> source)
+        public AutoEntityUnionTable<TInterface, TEntity> AliasField<TType>(Expression<Func<TInterface, TType>> target, Expression<Func<TEntity, TType>> source)
         {
-            var _tgt = new Column<TInterface>(target);
+            var _tgt = new Column<TInterface>(CoreUtils.GetFullPropertyName(target, "."));
             var _node = new ComplexFormulaFieldNode<TEntity, TType>(source);
             var _src = new ComplexColumn<TEntity, TType>(_tgt.Property, _node); 
             
@@ -94,9 +94,9 @@ namespace InABox.Core
             return this;
         }
         
-        public AutoEntityUnionTable<TInterface, TEntity> AliasField<TType>(Expression<Func<TInterface, object?>> target, IComplexFormulaNode<TEntity, TType> source)
+        public AutoEntityUnionTable<TInterface, TEntity> AliasField<TType>(Expression<Func<TInterface, TType>> target, IComplexFormulaNode<TEntity, TType> source)
         {
-            var _tgt = new Column<TInterface>(target);
+            var _tgt = new Column<TInterface>(CoreUtils.GetFullPropertyName(target, "."));
             var _src = new ComplexColumn<TEntity, TType>(_tgt.Property, source); 
             
             _mappings.Add(new AutoEntityUnionMapping(_src, _tgt));
@@ -112,12 +112,12 @@ namespace InABox.Core
             return this;
         }
         
-        public AutoEntityUnionTable<TInterface, TEntity> AliasField(Expression<Func<TInterface, object?>> target, string formatString, params Expression<Func<TEntity, object?>>[] fields)
+        public AutoEntityUnionTable<TInterface, TEntity> AliasField(Expression<Func<TInterface, string>> target, string formatString, params Expression<Func<TEntity, object?>>[] fields)
         {
-            var _tgt = new Column<TInterface>(target);
+            var _tgt = new Column<TInterface>(CoreUtils.GetFullPropertyName(target, "."));
             var _o = fields.Select(x => new ComplexFormulaFieldNode<TEntity, object?>(x));
             var _o2 = _o.OfType<IComplexFormulaNode<TEntity, object?>>().ToList()
-                .Prepend(new ComplexFormulaConstantNode<TEntity, object>(formatString))
+                .Prepend(new ComplexFormulaConstantNode<TEntity, object?>(formatString))
                 .ToArray();
             var _n = new ComplexFormulaFormulaNode<TEntity, object?>(_o2, FormulaOperator.Format);
             //var _node = new ComplexFormulaFieldNode<TEntity, TType>(source);