internal static string ToSelect <TModel>(IOrmLiteDialectProvider dialectProvider, Type fromTableType, string sqlFilter, Expression <Func <TModel, object> > onlyFields = null)
        {
            var sql      = StringBuilderCache.Allocate();
            var modelDef = onlyFields != null ? ModelDefinition <TModel> .DynamicDefinition(onlyFields.GetFieldNames().ToList()) : ModelDefinition <TModel> .Definition;

            sql.Append(
                $"SELECT {dialectProvider.GetColumnNames(modelDef)} " +
                $"FROM {dialectProvider.GetQuotedTableName(fromTableType.GetModelDefinition())}");

            if (string.IsNullOrEmpty(sqlFilter))
            {
                return(StringBuilderCache.ReturnAndFree(sql));
            }

            sql.Append(" WHERE ");
            sql.Append(sqlFilter);
            return(StringBuilderCache.ReturnAndFree(sql));
        }