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(
new string(
'(', Math.Max(
0, selectExpression
'(',
Math.Max(
0,
selectExpression
.Tables
.Count(t => !(t is CrossJoinExpression || t is CrossApplyExpression)) - maxTablesWithoutBrackets)));
for (var index = 0; index < selectExpression.Tables.Count; index++)
{
var tableExpression = selectExpression.Tables[index];
var isApplyExpression = tableExpression is CrossApplyExpression ||
tableExpression is OuterApplyExpression;
var isCrossExpression = tableExpression is CrossJoinExpression ||
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 (isCrossExpression)
{
Sql.Append(",");
}
else if (index >= maxTablesWithoutBrackets &&
index < selectExpression.Tables.Count - 1)
{
Sql.Append(")");
}
Sql.AppendLine();
}
Visit(tableExpression);
if (!isCrossExpression &&
index >= maxTablesWithoutBrackets)
{
Sql.Append(")");
}
}
}
else

Loading…
Cancel
Save