public string GetSql(bool endOfStatement = true) { var table = Reflection.GetTableName <T>(); var result = TemplateLibrary.Select; result.Append(SnippetLibrary.Table(table, TableAlias)); result.Append(SnippetLibrary.Columns(Columns.GetSql(TableAlias))); if (Join.Count > 0) { var joinTable = string.IsNullOrEmpty(TableAlias) ? table : TableAlias; result.Append(SnippetLibrary.Join(Join.GetSql(joinTable))); } if (Where.Count > 0) { result.Append(SnippetLibrary.Where(Where.GetSql(TableAlias))); } if (GroupBy.Count > 0) { result.Append(SnippetLibrary.GroupBy(GroupBy.GetSql(TableAlias))); } if (OrderBy.Count > 0) { result.Append(SnippetLibrary.OrderBy(OrderBy.GetSql(TableAlias))); } return(result.GetSql(endOfStatement)); }