private void AssertInvolved(string rootClassName, string expression, params string[] expectedClassNames) { SoqlExpression expr = SoqlParser.ParseExpression(expression); ClassInfo rootClass = _DatabaseSchema.GetSchema().FindClassByName(rootClassName); GetInvolvedClassesVisitor visitor = new GetInvolvedClassesVisitor(rootClass); expr.Accept(visitor); CollectionAssert.AreEquivalent(expectedClassNames, visitor.ClassNames); }
public SoodaObjectListSnapshot(SoodaTransaction t, SoodaWhereClause whereClause, SoodaOrderBy orderBy, int startIdx, int pageCount, SoodaSnapshotOptions options, ClassInfo ci) { this.classInfo = ci; string[] involvedClasses = null; bool useCache; if ((options & SoodaSnapshotOptions.NoCache) != 0) { useCache = false; } else if ((options & SoodaSnapshotOptions.Cache) != 0) { useCache = true; } else { useCache = t.CachingPolicy.ShouldCacheCollection(ci, whereClause, orderBy, startIdx, pageCount); } if (whereClause != null && whereClause.WhereExpression != null) { if ((options & SoodaSnapshotOptions.NoWriteObjects) == 0 || useCache) { try { GetInvolvedClassesVisitor gic = new GetInvolvedClassesVisitor(classInfo); gic.GetInvolvedClasses(whereClause.WhereExpression); involvedClasses = gic.ClassNames; } catch { // logger.Warn("{0}", ex); // cannot detect involved classes (probably because of RAWQUERY) // - precommit all objects // if we get here, involvedClasses remains set to null } } } else { // no where clause involvedClasses = new string[] { ci.Name }; } if ((options & SoodaSnapshotOptions.NoWriteObjects) == 0) { t.PrecommitClasses(involvedClasses); } LoadList(t, whereClause, orderBy, startIdx, pageCount, options, involvedClasses, useCache); }