public override void VisitResultOperator(Remotion.Linq.Clauses.ResultOperatorBase resultOperator, QueryModel queryModel, int index) { bool first = true; _queryAsString.AppendFormat("{0}(", resultOperator.GetType().Name); resultOperator.TransformExpressions(e => { string comma = ", "; if (first) { comma = ""; first = false; } _queryAsString.AppendFormat("{0}{1}", comma, ExpressionStringConverter.Format(e)); return(e); }); _queryAsString.Append(")"); }
public override void VisitResultOperator(Remotion.Linq.Clauses.ResultOperatorBase resultOperator, QueryModel queryModel, int index) { if (index > 0) { _isInstanceQuery = false; } if (resultOperator is TakeResultOperator) { var take = resultOperator as TakeResultOperator; _queryBuilder.Limit = take.GetConstantCount(); if (_queryBuilder.Limit != 1) { _isInstanceQuery = false; } return; } if (resultOperator is SkipResultOperator) { var skip = resultOperator as SkipResultOperator; _queryBuilder.Offset = skip.GetConstantCount(); return; } if (resultOperator is AverageResultOperator && index == 0) { var varName = GetExpressionVariable(queryModel.SelectClause.Selector); if (varName != null) { _queryBuilder.ApplyAggregate("AVG", varName); return; } } if (resultOperator is SumResultOperator && index == 0) { var varName = GetExpressionVariable(queryModel.SelectClause.Selector); if (varName != null) { _queryBuilder.ApplyAggregate("SUM", varName); return; } } if (resultOperator is CountResultOperator && index == 0) { var varName = GetExpressionVariable(queryModel.SelectClause.Selector); if (varName != null) { _queryBuilder.ApplyAggregate("COUNT", varName); return; } } if (resultOperator is LongCountResultOperator && index == 0) { var varName = GetExpressionVariable(queryModel.SelectClause.Selector); if (varName != null) { _queryBuilder.ApplyAggregate("COUNT", varName); return; } } if (resultOperator is MinResultOperator && index == 0) { var varName = GetExpressionVariable(queryModel.SelectClause.Selector); if (varName != null) { _queryBuilder.ApplyAggregate("MIN", varName); return; } } if (resultOperator is MaxResultOperator && index == 0) { var varName = GetExpressionVariable(queryModel.SelectClause.Selector); if (varName != null) { _queryBuilder.ApplyAggregate("MAX", varName); return; } } if (resultOperator is SingleResultOperator && index == 0) { // Grab first 2 rows. If there are two then the outer wrapper will fail. _queryBuilder.Limit = 2; return; } if (resultOperator is FirstResultOperator) { _queryBuilder.Limit = 1; return; } if (resultOperator is OfTypeResultOperator) { var ofType = resultOperator as OfTypeResultOperator; var varName = GetExpressionVariable(queryModel.SelectClause.Selector); if (varName != null) { var typeUri = _queryBuilder.Context.MapTypeToUri(ofType.SearchedItemType); if (typeUri != null) { _queryBuilder.AddTripleConstraint( GraphNode.Variable, varName, GraphNode.Raw, "a", GraphNode.Iri, typeUri); return; } throw new EntityFrameworkException("No URI mapping found for type '{0}'", ofType.SearchedItemType); } } if (resultOperator is DistinctResultOperator) { _queryBuilder.IsDistinct = true; return; } if (resultOperator is GroupResultOperator) { var groupOperator = resultOperator as GroupResultOperator; var keyExpr = groupOperator.KeySelector; var exprVar = GetExpressionVariable(keyExpr); if (exprVar == null) { throw new EntityFrameworkException("Unable to convert GroupBy '{0}' operator to SPARQL.", groupOperator); } _queryBuilder.AddGroupByExpression("?" + exprVar); return; } if (resultOperator is CastResultOperator) { var castOperator = resultOperator as CastResultOperator; var mappedUri = _queryBuilder.Context.MapTypeToUri(castOperator.CastItemType); if (mappedUri == null) { throw new EntityFrameworkException("Unable to cast to type '{0}' as it is not a valid entity type.", castOperator.CastItemType); } return; } if (index > 0) { throw new NotSupportedException( String.Format( "LINQ-to-SPARQL does not currently support the result operator '{0}' as a second or subsequent result operator.", resultOperator)); } throw new NotSupportedException( String.Format("LINQ-to-SPARQL does not currently support the result operator '{0}'", resultOperator)); }
public Tuple <bool, Expression> ProcessIdentityQuery(Remotion.Linq.Clauses.ResultOperatorBase resultOperator, Remotion.Linq.QueryModel queryModel, IGeneratedQueryCode _codeEnv, ICodeContext _codeContext, CompositionContainer container) { return(null); }
public Expression ProcessResultOperator(Remotion.Linq.Clauses.ResultOperatorBase resultOperator, Remotion.Linq.QueryModel queryModel, IGeneratedQueryCode _codeEnv, ICodeContext codeContext, CompositionContainer container) { throw new NotImplementedException(); }