public void SimpleSelect() { var expression = SelectTestQueryGenerator.CreateSimpleQuery(QuerySource).Expression; var queryModel = QueryParser.GetParsedQuery(expression); var selectClause = queryModel.SelectClause; CheckResolvedExpression <Cook, Cook> (selectClause.Selector, queryModel.MainFromClause, s => s); }
public void GenerateQueryModel() { Expression expression = SelectTestQueryGenerator.CreateSimpleQuery_SelectExpression(ExpressionHelper.CreateQueryable <Cook> ()); _queryParserMock .Expect(mock => mock.GetParsedQuery(expression)) .Return(_fakeQueryModel); _queryParserMock.Replay(); var queryModel = _queryProvider.GenerateQueryModel(expression); _queryParserMock.VerifyAllExpectations(); Assert.That(queryModel, Is.SameAs(_fakeQueryModel)); }
public void TreeWithSubquery() { Expression subQuery = SelectTestQueryGenerator.CreateSimpleQuery(ExpressionHelper.CreateQueryable <Cook>()).Expression; Expression surroundingExpression = Expression.Lambda(subQuery); Expression newExpression = SubQueryFindingExpressionTreeVisitor.Process(surroundingExpression, _methodInfoBasedNodeTypeRegistry); Assert.That(newExpression, Is.Not.SameAs(surroundingExpression)); Assert.That(newExpression, Is.InstanceOf(typeof(LambdaExpression))); var newLambdaExpression = (LambdaExpression)newExpression; Assert.That(newLambdaExpression.Body, Is.InstanceOf(typeof(SubQueryExpression))); var newSubQueryExpression = (SubQueryExpression)newLambdaExpression.Body; Assert.That( ((QuerySourceReferenceExpression)newSubQueryExpression.QueryModel.SelectClause.Selector).ReferencedQuerySource, Is.SameAs(newSubQueryExpression.QueryModel.MainFromClause)); }