Fix join statement generation.

pull/48/head
Lau 6 years ago
parent 48bc49d3a4
commit d80b53e9b2

@ -106,34 +106,44 @@ namespace EntityFrameworkCore.Jet.Query.Sql.Internal
Sql.Append( Sql.Append(
new string( new string(
'(', Math.Max( '(',
0, selectExpression Math.Max(
0,
selectExpression
.Tables .Tables
.Count(t => !(t is CrossJoinExpression || t is CrossApplyExpression)) - maxTablesWithoutBrackets))); .Count(t => !(t is CrossJoinExpression || t is CrossApplyExpression)) - maxTablesWithoutBrackets)));
for (var index = 0; index < selectExpression.Tables.Count; index++) for (var index = 0; index < selectExpression.Tables.Count; index++)
{ {
var tableExpression = selectExpression.Tables[index]; var tableExpression = selectExpression.Tables[index];
var isApplyExpression = tableExpression is CrossApplyExpression ||
tableExpression is OuterApplyExpression;
var isCrossExpression = tableExpression is CrossJoinExpression || var isCrossExpression = tableExpression is CrossJoinExpression ||
tableExpression is CrossApplyExpression; tableExpression is CrossApplyExpression;
if (isApplyExpression)
{
throw new InvalidOperationException("Jet does not support APPLY statements. Switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync() if needed.");
}
if (index > 0) if (index > 0)
{ {
if (isCrossExpression) if (isCrossExpression)
{ {
Sql.Append(","); Sql.Append(",");
} }
else if (index >= maxTablesWithoutBrackets &&
index < selectExpression.Tables.Count - 1)
{
Sql.Append(")");
}
Sql.AppendLine(); Sql.AppendLine();
} }
Visit(tableExpression); Visit(tableExpression);
if (!isCrossExpression &&
index >= maxTablesWithoutBrackets)
{
Sql.Append(")");
}
} }
} }
else else

Loading…
Cancel
Save