Kenric Nugteren 4 недель назад
Родитель
Сommit
262a141cb1
2 измененных файлов с 42 добавлено и 150 удалено
  1. 12 28
      InABox.Core/Objects/Attributes/Aggregate.cs
  2. 30 122
      inabox.database.sqlite/SQLiteProvider.cs

+ 12 - 28
InABox.Core/Objects/Attributes/Aggregate.cs

@@ -325,19 +325,16 @@ namespace InABox.Core
 
         public Condition Condition { get; set; }
         
-        public object? Coalesce { get; set; }
-
-        public ComplexFormulaPartial0ConditionNode(IComplexFormulaNode<TType, TCondition> left, IComplexFormulaNode<TType, TCondition> right, Condition condition, object? coalesce)
+        public ComplexFormulaPartial0ConditionNode(IComplexFormulaNode<TType, TCondition> left, IComplexFormulaNode<TType, TCondition> right, Condition condition)
         {
             Left = left;
             Right = right;
             Condition = condition;
-            Coalesce = coalesce;
         }
 
         public ComplexFormulaPartial1ConditionNode<TType, TCondition, TValue> Then(IComplexFormulaNode<TType, TValue> then)
         {
-            return new ComplexFormulaPartial1ConditionNode<TType, TCondition, TValue>(Left, Right, Condition, then, Coalesce);
+            return new ComplexFormulaPartial1ConditionNode<TType, TCondition, TValue>(Left, Right, Condition, then);
         }
     }
 
@@ -350,21 +347,18 @@ namespace InABox.Core
         public IComplexFormulaNode<TType, TValue> True { get; set; }
 
         public Condition Condition { get; set; }
-        
-        public object? Coalesce { get; set; }
 
-        public ComplexFormulaPartial1ConditionNode(IComplexFormulaNode<TType, TCondition> left, IComplexFormulaNode<TType, TCondition> right, Condition condition, IComplexFormulaNode<TType, TValue> trueValue, object? coalesce)
+        public ComplexFormulaPartial1ConditionNode(IComplexFormulaNode<TType, TCondition> left, IComplexFormulaNode<TType, TCondition> right, Condition condition, IComplexFormulaNode<TType, TValue> trueValue)
         {
             Left = left;
             Right = right;
             Condition = condition;
             True = trueValue;
-            Coalesce = coalesce;
         }
 
         public ComplexFormulaConditionNode<TType, TCondition, TValue> Else(IComplexFormulaNode<TType, TValue> elseValue)
         {
-            return new ComplexFormulaConditionNode<TType, TCondition, TValue>(Left, Right, True, elseValue, Condition, Coalesce);
+            return new ComplexFormulaConditionNode<TType, TCondition, TValue>(Left, Right, True, elseValue, Condition);
         }
     }
 
@@ -381,9 +375,6 @@ namespace InABox.Core
         public IComplexFormulaNode False { get; }
 
         public Condition Condition { get; }
-        
-        public object? Coalesce { get; }
-        
     }
     public class ComplexFormulaConditionNode<TType, TCondition, TValue> : IComplexFormulaNode<TType, TValue>, IComplexFormulaConditionNode
     {
@@ -399,16 +390,13 @@ namespace InABox.Core
 
         public Condition Condition { get; set; }
         
-        public object? Coalesce { get; }
-        
-        public ComplexFormulaConditionNode(IComplexFormulaNode<TType, TCondition> left, IComplexFormulaNode<TType, TCondition> right, IComplexFormulaNode<TType, TValue> trueValue, IComplexFormulaNode<TType, TValue> falseValue, Condition condition, object? coalesce)
+        public ComplexFormulaConditionNode(IComplexFormulaNode<TType, TCondition> left, IComplexFormulaNode<TType, TCondition> right, IComplexFormulaNode<TType, TValue> trueValue, IComplexFormulaNode<TType, TValue> falseValue, Condition condition)
         {
             Left = left;
             Right = right;
             True = trueValue;
             False = falseValue;
             Condition = condition;
-            Coalesce = coalesce;
         }
 
         IComplexFormulaNode IComplexFormulaConditionNode.Left => Left;
@@ -482,10 +470,9 @@ namespace InABox.Core
         public static ComplexFormulaPartial0ConditionNode<TType, TCondition, TValue> If<TType, TCondition, TValue>(
             IComplexFormulaNode<TType, TCondition> left,
             Condition condition,
-            IComplexFormulaNode<TType, TCondition> right,
-            object? coalesce = null)
+            IComplexFormulaNode<TType, TCondition> right)
         {
-            return new ComplexFormulaPartial0ConditionNode<TType, TCondition, TValue>(left, right, condition, coalesce);
+            return new ComplexFormulaPartial0ConditionNode<TType, TCondition, TValue>(left, right, condition);
         }
     }
 
@@ -520,8 +507,7 @@ namespace InABox.Core
         ComplexFormulaPartial0ConditionNode<TType, TCondition, TResult> If<TCondition>(
             Func<IComplexFormulaGenerator<TType, TCondition>, IComplexFormulaNode<TType, TCondition>> left,
             Condition condition,
-            Func<IComplexFormulaGenerator<TType, TCondition>, IComplexFormulaNode<TType, TCondition>> right,
-            object? coalesce);
+            Func<IComplexFormulaGenerator<TType, TCondition>, IComplexFormulaNode<TType, TCondition>> right);
     }
 
     internal class InternalComplexFormulaGenerator<TType, TResult> : IComplexFormulaGenerator<TType, TResult>
@@ -561,15 +547,13 @@ namespace InABox.Core
         public ComplexFormulaPartial0ConditionNode<TType, TCondition, TResult> If<TCondition>(
             Func<IComplexFormulaGenerator<TType, TCondition>, IComplexFormulaNode<TType, TCondition>> left,
             Condition condition,
-            Func<IComplexFormulaGenerator<TType, TCondition>, IComplexFormulaNode<TType, TCondition>> right,
-            object? coalesce)
+            Func<IComplexFormulaGenerator<TType, TCondition>, IComplexFormulaNode<TType, TCondition>> right)
         {
             var generator = new InternalComplexFormulaGenerator<TType, TCondition>();
             return ComplexFormulaGenerator.If<TType, TCondition, TResult>(
                 left(generator),
                 condition,
-                right(generator),
-                coalesce);
+                right(generator));
         }
 
         public IComplexFormulaNode<TType, int> Count<TAggregate, TExpression>(Func<IComplexFormulaGenerator<TAggregate, TExpression>, IComplexFormulaNode<TAggregate, TExpression>> expression, KeyValuePair<Expression<Func<TAggregate, object?>>, Expression<Func<TType, object?>>>[] links, Filter<TAggregate>? filter = null)
@@ -625,9 +609,9 @@ namespace InABox.Core
             return ((IComplexFormulaGenerator<TType, TResult>)InternalGenerator).Aggregate(calculation, expression, filter);
         }
 
-        public ComplexFormulaPartial0ConditionNode<TType, TCondition, TResult> If<TCondition>(Func<IComplexFormulaGenerator<TType, TCondition>, IComplexFormulaNode<TType, TCondition>> left, Condition condition, Func<IComplexFormulaGenerator<TType, TCondition>, IComplexFormulaNode<TType, TCondition>> right, object? coalesce = null)
+        public ComplexFormulaPartial0ConditionNode<TType, TCondition, TResult> If<TCondition>(Func<IComplexFormulaGenerator<TType, TCondition>, IComplexFormulaNode<TType, TCondition>> left, Condition condition, Func<IComplexFormulaGenerator<TType, TCondition>, IComplexFormulaNode<TType, TCondition>> right)
         {
-            return ((IComplexFormulaGenerator<TType, TResult>)InternalGenerator).If(left, condition, right, coalesce);
+            return ((IComplexFormulaGenerator<TType, TResult>)InternalGenerator).If(left, condition, right);
         }
 
         public IComplexFormulaNode<TType, int> Count<TAggregate, TExpression>(Func<IComplexFormulaGenerator<TAggregate, TExpression>, IComplexFormulaNode<TAggregate, TExpression>> expression, KeyValuePair<Expression<Func<TAggregate, object?>>, Expression<Func<TType, object?>>>[] links, Filter<TAggregate>? filter = null)

+ 30 - 122
inabox.database.sqlite/SQLiteProvider.cs

@@ -1760,7 +1760,7 @@ public class SQLiteProvider : IProvider
         return CoreUtils.ChangeType(o, type);
     }
 
-    public static object Encode(object? o, Type? type, bool convertToNull = true)
+    public static object Encode(object? o, Type? type)
     {
         if (IsNull(o) || type is null)
             return DBNull.Value;
@@ -1809,16 +1809,9 @@ public class SQLiteProvider : IProvider
 
         if (type == typeof(bool))
         {
-            if (convertToNull && o.Equals(false))
-                return DBNull.Value;
             return o.Equals(true) ? "1" : "0";
         }
 
-        if (convertToNull && type == typeof(string) && string.IsNullOrEmpty(o.ToString()))
-            return DBNull.Value;
-
-
-
         if (o is string[] sArray)
         {
 
@@ -1845,42 +1838,18 @@ public class SQLiteProvider : IProvider
             return ms.ToArray();
         }
 
-        if (convertToNull)
-        {
-            if (o is double d && d == default)
-                return DBNull.Value;
-
-            if (o is float f && f == default)
-                return DBNull.Value;
-
-            if (o is int i && i == default)
-                return DBNull.Value;
-
-            if (o is long l && l == default)
-                return DBNull.Value;
-
-            if (o is decimal dec && dec == default)
-                return DBNull.Value;
-        }
-
         if (o is DateTime dateTime)
         {
-            if (convertToNull && dateTime == DateTime.MinValue)
-                return DBNull.Value;
             return string.Format("{0:yyyy-MM-dd HH:mm:ss.FFFFFFF}", o);
         }
 
         if (o is TimeSpan timeSpan)
         {
-            if (convertToNull && timeSpan.Ticks == 0L)
-                return DBNull.Value;
             return timeSpan.TotalHours;
         }
 
         if (o is Guid id)
         {
-            if (convertToNull && id == Guid.Empty)
-                return DBNull.Value;
             return o.ToString() ?? "";
         }
 
@@ -1898,9 +1867,9 @@ public class SQLiteProvider : IProvider
         { Operator.IsGreaterThanOrEqualTo, "{0} >= {1}" },
         { Operator.IsLessThan, "{0} < {1}" },
         { Operator.IsLessThanOrEqualTo, "{0} <= {1}" },
-        { Operator.BeginsWith, "IFNULL({0},'') LIKE {1} || '%'" },
-        { Operator.Contains, "IFNULL({0},'') LIKE '%' || {1} || '%'" },
-        { Operator.EndsWith, "IFNULL({0},'') LIKE '%' || {1}" },
+        { Operator.BeginsWith, "{0} LIKE {1} || '%'" },
+        { Operator.Contains, "{0} LIKE '%' || {1} || '%'" },
+        { Operator.EndsWith, "{0} LIKE '%' || {1}" },
         { Operator.InList, "{0} IN ({1})" },
         { Operator.NotInList, "{0} NOT IN ({1})" },
         { Operator.InQuery, "{0} IN ({1})" },
@@ -2101,10 +2070,6 @@ public class SQLiteProvider : IProvider
                         result = string.Format("(" + operators[filter.Operator] + ")",
                             prop,
                             string.Join(',', list.Where(x => x != Guid.Empty).Select(x => $"'{x}'")));
-                        if (list.Contains(Guid.Empty))
-                        {
-                            result = $"({result} or ({prop} IS NULL))";
-                        }
                     }
                     else if (filter.Value is IEnumerable enumerable)
                     {
@@ -2142,16 +2107,10 @@ public class SQLiteProvider : IProvider
             {
                 if(filter.Value is FilterConstant constant)
                 {
-                    if (constant == FilterConstant.Null)
-                    {
-                        result = string.Format("({0} {1} NULL)", prop,
-                            filter.Operator == Operator.IsEqualTo
-                                ? "IS"
-                                : "IS NOT");
-                    }
-                    else
-                        result = string.Format("(" + operators[filter.Operator] + ")", prop,
-                            GetFilterConstant(constant));
+                    result = string.Format("(" + operators[filter.Operator] + ")", prop,
+                        constant == FilterConstant.Null
+                        ? EscapeValue(GetColumnDefaultValue(filter.Type))
+                        : GetFilterConstant(constant));
                 }
                 else
                 {
@@ -2173,20 +2132,18 @@ public class SQLiteProvider : IProvider
                     }
                     else
                     {
-                        var strProp = $"IFNULL({prop},{EscapeValue(GetColumnDefaultValue(filter.Type))})";
                         value = useparams ? EncodeParameter(command, value) : EscapeValue(filter.Value);
-                        result = string.Format("(" + operators[filter.Operator] + ")", strProp, value);
+                        result = string.Format("(" + operators[filter.Operator] + ")", prop, value);
                     }
                 }
             }
             else
             {
-                var strProp = $"IFNULL({prop},{EscapeValue(GetColumnDefaultValue(filter.Type))})";
                 var strValue = filter.Value is FilterConstant constant
                     ? constant == FilterConstant.Null ? EscapeValue(GetColumnDefaultValue(filter.Type)) : GetFilterConstant(constant)
-                    : useparams ? EncodeParameter(command, Encode(filter.Value, filter.Type, convertToNull: false)) : EscapeValue(filter.Value);
+                    : useparams ? EncodeParameter(command, Encode(filter.Value, filter.Type)) : EscapeValue(filter.Value);
 
-                result = string.Format($"({operators[filter.Operator]})", strProp, strValue);
+                result = string.Format($"({operators[filter.Operator]})", prop, strValue);
             }
 
             if (filter.IsNot)
@@ -2322,31 +2279,31 @@ public class SQLiteProvider : IProvider
         }
 
         if (attribute.Operator == FormulaOperator.Add)
-            return string.Format("(IFNULL({0},0.00) + {1})", 
+            return string.Format("({0} + {1})", 
                 fieldmap.TryGetValue(attribute.Value, out var _value) ? _value : attribute.Value,
-                string.Join(" + ", attribute.Modifiers.Select(x => fieldmap.TryGetValue(x, out var _value) ? $"IFNULL({_value},0.00)" : $"{x}")));
+                string.Join(" + ", attribute.Modifiers.Select(x => fieldmap.TryGetValue(x, out var _value) ? $"{_value}" : $"{x}")));
 
         if (attribute.Operator == FormulaOperator.Subtract)
-            return string.Format("(IFNULL({0},0.00) - ({1}))", 
+            return string.Format("({0} - ({1}))", 
                 fieldmap.TryGetValue(attribute.Value, out var _value) ? _value : attribute.Value,
-                string.Join(" + ", attribute.Modifiers.Select(x => fieldmap.TryGetValue(x, out var _value) ? $"IFNULL({_value},0.00)" : $"{x}")));
+                string.Join(" + ", attribute.Modifiers.Select(x => fieldmap.TryGetValue(x, out var _value) ? $"{_value}" : $"{x}")));
 
         if (attribute.Operator == FormulaOperator.Multiply)
-            return string.Format("(IFNULL({0},0.00) * {1})", 
+            return string.Format("({0} * {1})", 
                 fieldmap.TryGetValue(attribute.Value, out var _value) ? _value : attribute.Value,
-                string.Join(" * ", attribute.Modifiers.Select(x => fieldmap.TryGetValue(x, out var _value) ? $"IFNULL({_value},0.00)" : $"{x}")));
+                string.Join(" * ", attribute.Modifiers.Select(x => fieldmap.TryGetValue(x, out var _value) ? $"{_value}" : $"{x}")));
 
         if (attribute.Operator == FormulaOperator.Divide)
         {
-            var result = string.Format("IFNULL({0},0.00)", fieldmap.TryGetValue(attribute.Value, out var _v) ? _v : attribute.Value);
+            var result = string.Format("{0}", fieldmap.TryGetValue(attribute.Value, out var _v) ? _v : attribute.Value);
             foreach (var modifier in attribute.Modifiers)
-                result = string.Format("({0} / {1})", result, fieldmap.TryGetValue(modifier, out var _value) ? $"IFNULL({_value},1.00)" : $"{modifier}");
+                result = string.Format("({0} / {1})", result, fieldmap.TryGetValue(modifier, out var _value) ? $"{_value}" : $"{modifier}");
             return result;
         }
 
         if (attribute.Operator == FormulaOperator.Maximum)
         {
-            var parameters = attribute.Modifiers.Select(m => fieldmap.TryGetValue(m, out var _value) ? $"IFNULL({_value},0.00)" : $"{m}");
+            var parameters = attribute.Modifiers.Select(m => fieldmap.TryGetValue(m, out var _value) ? $"{_value}" : $"{m}");
             var primary = fieldmap.TryGetValue(attribute.Value, out var _v) ? _v : attribute.Value;
             var result = $"MAX({primary}, {String.Join(", ", parameters)})";
             return result;
@@ -2354,7 +2311,7 @@ public class SQLiteProvider : IProvider
 
         if (attribute.Operator == FormulaOperator.Minumum)
         {
-            var parameters = attribute.Modifiers.Select(m => fieldmap.TryGetValue(m, out var _value) ? $"IFNULL({_value},0.00)" : $"{m}");
+            var parameters = attribute.Modifiers.Select(m => fieldmap.TryGetValue(m, out var _value) ? $"{_value}" : $"{m}");
             var primary = fieldmap.TryGetValue(attribute.Value, out var _v) ? _v : attribute.Value;
             var result = $"MIN({primary}, {String.Join(", ", parameters)})";
             return result;
@@ -2413,8 +2370,7 @@ public class SQLiteProvider : IProvider
             ? _falsevalue
             : EscapeValue(attribute.False, valuetype);
 
-        return string.Format("CASE WHEN COALESCE({0},{1}) {2} {3} THEN {4} ELSE {5} END", _left, defvalue, condition,
-            _right, _true, _false);
+        return string.Format("CASE WHEN {0} {1} {2} THEN {3} ELSE {4} END", _left, condition, _right, _true, _false);
     }
 
     public string LoadComplexFormula(SQLiteCommand command, Type type, char prefix, Dictionary<string, string> fieldmap, List<Tuple<string, string, string, string>> tables, List<string> columns, IComplexFormulaNode node, bool useparams)
@@ -2461,7 +2417,7 @@ public class SQLiteProvider : IProvider
                     var joins = new List<string>();
 
                     foreach (var (key, link) in links)
-                        joins.Add(string.Format("IFNULL({0}{1}.[{2}],'') = IFNULL({0}1.[{3}],'')", prefix, alias, key, link));
+                        joins.Add(string.Format("{0}{1}.[{2}] = {0}1.[{3}]", prefix, alias, key, link));
 
                     var join = string.Format("LEFT OUTER JOIN {0} {1}{2} ON {3}", subquery, prefix, alias,
                         string.Join(" AND ", joins));
@@ -2498,22 +2454,11 @@ public class SQLiteProvider : IProvider
                 LoadFieldsAndTables(command, type, prefix, fieldmap, tables, columns, col, useparams);
                 return fieldmap[col.Name];
             case IComplexFormulaFormulaNode formula:
-                var operands = new List<string>();
-                var op = formula.GetOperator();
-
-                bool bFirst = true;
-                foreach (var field in formula.GetOperands())
-                {
-                    var operand = LoadComplexFormula(command, type, prefix, fieldmap, tables, columns, field, useparams);
-                    if (op == FormulaOperator.Divide)
-                        operands.Add($"IFNULL({operand}, {(bFirst ? 0.00 : 1.00)})");
-                    else if (op == FormulaOperator.Format)
-                        operands.Add(operand);
-                    else
-                        operands.Add($"IFNULL({operand}, 0.00)");
-                    bFirst = true;
-                }
+                var operands = formula.GetOperands()
+                    .Select(x => LoadComplexFormula(command, type, prefix, fieldmap, tables, columns, x, useparams))
+                    .ToList();
 
+                var op = formula.GetOperator();
                 switch (op)
                 {
                     
@@ -2611,10 +2556,6 @@ public class SQLiteProvider : IProvider
                 var trueVal = LoadComplexFormula(command, type, prefix, fieldmap, tables, columns, condition.True, useparams);
                 var falseVal = LoadComplexFormula(command, type, prefix, fieldmap, tables, columns, condition.False, useparams);
                 
-                var coalesce = condition.Coalesce != null
-                    ? EscapeValue(condition.Coalesce)
-                    : EscapeValue(condition.TCondition.GetDefault());
-                
                 var conditionOp = condition.Condition switch
                 {
                     Condition.Equals => "=",
@@ -2625,7 +2566,7 @@ public class SQLiteProvider : IProvider
                     Condition.LessThanOrEqualTo => "<=",
                     _ => throw new Exception($"{condition.Condition} is not a valid condition")
                 };
-                return $"(CASE WHEN COALESCE({left}, {coalesce}) {conditionOp} {right} THEN " +
+                return $"(CASE WHEN {left} {conditionOp} {right} THEN " +
                     $" {trueVal} ELSE {falseVal} END)";
             default:
                 throw new Exception($"Unknown ComplexFormula type {node.GetType()}");
@@ -2669,17 +2610,6 @@ public class SQLiteProvider : IProvider
                                 var scols = new Dictionary<string, string> { { agg.Aggregate, GetCalculation(agg.Calculation, baseCol.Name, baseCol.Type) } };
 
                                 var linkedtype = agg.Source;
-                                /*var siblings = columns.Where(x => !x.Equals(baseCol.Name) && x.Split('.').First().Equals(bits.First()))
-                                    .Select(x => string.Join(".", x.Split('.').Skip(1))).ToList();
-                                foreach (var sibling in siblings)
-                                {
-                                    var sprop = CoreUtils.GetProperty(type, sibling);
-                                    var sattr = prop.GetCustomAttributes().FirstOrDefault(x => x.GetType().Equals(typeof(AggregateAttribute)));
-                                    if (sattr is AggregateAttribute sagg)
-                                    {
-                                        scols[sagg.Aggregate] = GetCalculation(sagg, sibling);
-                                    }
-                                }*/
 
                                 var subcols = Columns.None(linkedtype);
 
@@ -2706,27 +2636,15 @@ public class SQLiteProvider : IProvider
 
                                     foreach (var key in agg.Links.Keys)
                                         joins.Add(
-                                            string.Format("IFNULL({0}{1}.[{2}],'') = IFNULL({0}1.[{3}],'')", prefix, alias, key, agg.Links[key]));
+                                            string.Format("{0}{1}.[{2}] = {0}1.[{3}]", prefix, alias, key, agg.Links[key]));
                                     var join = string.Format("LEFT OUTER JOIN {0} {1}{2} ON {3}", linkedtable, prefix, alias,
                                         string.Join(" AND ", joins));
                                     tuple = new Tuple<string, string, string, string>(linkedtable, prefix + alias.ToString(), join, link);
 
-                                    //tuple = new Tuple<String, String, String, String>(linkedtable, prefix + alias.ToString(), String.Format("LEFT OUTER JOIN {0} {1}{2} ON {1}{2}.[{3}] = {1}1.[ID]", linkedtable, prefix, alias, agg.Link), link);
-
                                     tables.Add(tuple);
                                 }
 
-                                //if (bits.Last().Equals("ID"))
-                                //    fieldmap[columnname] = String.Format("{0}1.[{1}]", prefix, columnname);
-                                //else
                                 fieldmap[baseCol.Name] = string.Format("{0}.[{1}]", tuple.Item2, agg.Aggregate);
-
-                                //LoadFieldsandTables(command, agg.Type, newprefix, fieldmap, tables, columns, columnname);
-                                //var linkedtable = String.Format("(SELECT [{3}],{0}([{1}]) as [{1}] from {2} group by [{3}])", GetCalculation(agg, columnname), agg.AggregateProperty, agg.Type.EntityName().Split('.').Last(), agg.LinkedProperty);
-                                //int alias = tables.Count + 1;
-                                //var tuple = new Tuple<String, String, String, String>(linkedtable, prefix + alias.ToString(), String.Format("LEFT OUTER JOIN {0} {1}{2} ON {1}{2}.[{3}] = {1}1.[ID]", linkedtable, prefix, alias, agg.LinkedProperty), "");
-                                //tables.Add(tuple);
-                                //fieldmap[columnname] = String.Format("{0}.[{1}]", tuple.Item2, agg.AggregateProperty);
                             }
                         }
                         else if (property.GetAttribute<FormulaAttribute>() is FormulaAttribute fnc)
@@ -2846,9 +2764,6 @@ public class SQLiteProvider : IProvider
                                         tables.Add(tuple);
                                     }
 
-                                    //if (bits.Last().Equals("ID"))
-                                    //    fieldmap[columnname] = String.Format("{0}1.[{1}]", prefix, columnname);
-                                    //else
                                     fieldmap[baseCol.Name] = string.Format("{0}.[{1}]", tuple.Item2, string.Join(".", bits.Skip(combinecount)));
                                     foreach (var sibling in siblings)
                                     {
@@ -2887,16 +2802,13 @@ public class SQLiteProvider : IProvider
                                                     linkedtable,
                                                     prefix,
                                                     alias,
-                                                    string.Join(".", bits.Take(combinecount)) //prop.Name
+                                                    string.Join(".", bits.Take(combinecount))
                                                 ),
                                                 link
                                             );
                                             tables.Add(tuple);
                                         }
 
-                                        //if (bits.Last().Equals("ID"))
-                                        //    fieldmap[columnname] = String.Format("{0}1.[{1}]", prefix, columnname);
-                                        //else
                                         fieldmap[baseCol.Name] = string.Format("{0}.[{1}]", tuple.Item2, string.Join(".", bits.Skip(combinecount)));
                                         foreach (var sibling in siblings)
                                         {
@@ -2924,10 +2836,6 @@ public class SQLiteProvider : IProvider
                 }
                 else
                 {
-                    //IProperty customprop = DataModel.Property(type, columnname);
-                    //if (customprop != null)
-                    //    fieldmap[columnname] = String.Format("{0}1.[{1}]", prefix, columnname);
-                    //else
                     fieldmap[baseCol.Name] = baseCol.Name;
                 }
                 break;