Permalink
Browse files

Do no require anonymous type for transform results

  • Loading branch information...
1 parent e14639a commit 7458909c9e15573f5b9983be087214148a3592bd @ayende ayende committed Sep 16, 2011
Showing with 5 additions and 5 deletions.
  1. +3 −3 Raven.Database/Linq/DynamicViewCompiler.cs
  2. +2 −2 Raven.Database/Linq/QueryParsingUtils.cs
@@ -198,7 +198,7 @@ private void HandleTransformResults(ConstructorDeclaration ctor)
}
else
{
- translatorDeclaration = QueryParsingUtils.GetVariableDeclarationForLinqMethods(indexDefinition.TransformResults);
+ translatorDeclaration = QueryParsingUtils.GetVariableDeclarationForLinqMethods(indexDefinition.TransformResults,requiresSelectNewAnonymousType: false);
}
@@ -234,7 +234,7 @@ private void HandleReduceDefintion(ConstructorDeclaration ctor)
}
else
{
- reduceDefiniton = QueryParsingUtils.GetVariableDeclarationForLinqMethods(indexDefinition.Reduce);
+ reduceDefiniton = QueryParsingUtils.GetVariableDeclarationForLinqMethods(indexDefinition.Reduce, RequiresSelectNewAnonymousType);
var invocation = ((InvocationExpression) reduceDefiniton.Initializer);
var target = (MemberReferenceExpression) invocation.TargetObject;
while(target.MemberName!="GroupBy")
@@ -333,7 +333,7 @@ private static void AddInformation(ConstructorDeclaration ctor, HashSet<string>
private VariableDeclaration TransformMapDefinitionFromLinqMethodSyntax(string query, out string entityName)
{
- var variableDeclaration = QueryParsingUtils.GetVariableDeclarationForLinqMethods(query);
+ var variableDeclaration = QueryParsingUtils.GetVariableDeclarationForLinqMethods(query, RequiresSelectNewAnonymousType);
AddEntityNameFilteringIfNeeded(variableDeclaration, out entityName);
variableDeclaration.AcceptVisitor(new AddDocumentIdToLambdas(), null);
@@ -109,7 +109,7 @@ public static VariableDeclaration GetVariableDeclarationForLinqQuery(string quer
return variable;
}
- public static VariableDeclaration GetVariableDeclarationForLinqMethods(string query)
+ public static VariableDeclaration GetVariableDeclarationForLinqMethods(string query, bool requiresSelectNewAnonymousType)
{
var parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader("var q = " + query));
@@ -145,7 +145,7 @@ public static VariableDeclaration GetVariableDeclarationForLinqMethods(string qu
if (objectCreateExpression == null)
throw new InvalidOperationException("Variable initializer select must have a lambda expression with an object create expression");
- if (objectCreateExpression.IsAnonymousType == false && objectCreateExpression.CreateType.Type.Contains("Anonymous") == false)
+ if (objectCreateExpression.IsAnonymousType == false && objectCreateExpression.CreateType.Type.Contains("Anonymous") == false && requiresSelectNewAnonymousType)
throw new InvalidOperationException("Variable initializer select must have a lambda expression creating an anonymous type but returning " + objectCreateExpression.CreateType.Type);
variable.AcceptVisitor(new TransformNullCoalasingOperatorTransformer(), null);

0 comments on commit 7458909

Please sign in to comment.