protected override IBuildContext BuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo) { var sequence = builder.BuildSequence(new BuildInfo(buildInfo, methodCall.Arguments[0])); var take = 0; if (!buildInfo.IsSubQuery || builder.DataContextInfo.SqlProviderFlags.IsSubQueryTakeSupported) { switch (methodCall.Method.Name) { case "First": case "FirstOrDefault": take = 1; break; case "Single": case "SingleOrDefault": if (!buildInfo.IsSubQuery) { take = 2; } break; } } if (take != 0) { builder.BuildTake(sequence, new SqlValue(take)); } return(new FirstSingleContext(buildInfo.Parent, sequence, methodCall)); }