Skip to content

Commit

Permalink
Microsoft Access SELECT TOP syntax corrected. Closes #73.
Browse files Browse the repository at this point in the history
  • Loading branch information
hisystems committed Oct 5, 2012
1 parent 075ae48 commit 2fce073
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 6 additions & 1 deletion SQL/Serializers/MicrosoftAccessSerializer.cs
Expand Up @@ -14,7 +14,12 @@ namespace DatabaseObjects.SQL.Serializers
{
internal class MicrosoftAccessSerializer : MicrosoftSerializer
{
public override Database.ConnectionType Type
public MicrosoftAccessSerializer()
{
base.SerializeTopClauseWithParentheses = false;
}

public override Database.ConnectionType Type
{
get
{
Expand Down
12 changes: 11 additions & 1 deletion SQL/Serializers/MicrosoftSerializer.cs
Expand Up @@ -19,9 +19,19 @@ namespace DatabaseObjects.SQL.Serializers
/// </summary>
internal abstract class MicrosoftSerializer : Serializer
{
protected bool SerializeTopClauseWithParentheses = true;

public override string SerializeBeforeSelectFields(SQLSelect select)
{
var topClause = select.Top > 0 ? "TOP(" + select.Top.ToString() + ") " : String.Empty;
var topClause = String.Empty;

if (select.Top > 0)
{
if (SerializeTopClauseWithParentheses)
topClause = "TOP(" + select.Top.ToString() + ") ";
else
topClause = "TOP " + select.Top.ToString() + " ";
}

return base.SerializeBeforeSelectFields(select) + topClause;
}
Expand Down

0 comments on commit 2fce073

Please sign in to comment.