Exemplo n.º 1
0
 /// <summary>
 /// Inspects a query, ensuring it won't leak records and calculating the
 /// records and fields it uses.
 /// </summary>
 public RecordsAndFields InspectExpression(LambdaExpression node)
 {
     _RecordsAndFields = new RecordsAndFields();
     //first see if the node leaks any records:
     EnsureTypeWontLeakRecords(node.ReturnType);
     //visit the tree
     Visit(node);
     return(_RecordsAndFields);
 }
        private static RecordsAndFields VisitList <T>(ReadOnlyCollection <T> original, Func <T, RecordsAndFields> op)
        {
            RecordsAndFields @new = new RecordsAndFields();

            for (int i = 0, n = original.Count; i < n; i++)
            {
                @new += op(original[i]);
            }
            return(@new);
        }
        public static RecordsAndFields operator +(RecordsAndFields first, RecordsAndFields second)
        {
            var allTypes = new HashSet <Type>(first.Types);

            allTypes.UnionWith(second.Types);
            var rnf = new RecordsAndFields();

            foreach (var type in allTypes)
            {
                rnf.AddType(type);
                rnf.AddFields(type, first.GetFieldsForType(type));
                rnf.AddFields(type, second.GetFieldsForType(type));
            }
            return(rnf);
        }