Question: I have domains like that in Grails:

```
class Questao {

    static transients = [ "tags" ]

    String enunciado
    Double valorQuestao
    byte[] imagem
    public enum Tipo {
        ALTERNATIVAS,
        VF,
        SUBJETIVA
    }

    Tipo tipoQuestao

    static hasMany = [alternativas:Alternativas, assuntos: QuestaoAssunto, provas: Prova]

    static belongsTo = [Prova]

    static mapping = { enunciado type: 'text'}

    static constraints = {
        imagem nullable: true, maxSize: 160384
        alternativas nullable: true
    }
}

class QuestaoAssunto {

    Questao questao
    Assunto assunto

    static belongsTo = [Questao,Assunto]

}
class Assunto {

    String titulo

    static hasMany = [questoes:QuestaoAssunto]

    static belongsTo = [Questao]
}

```

and i need to execute this SQL:

```
select q.* from questao_assunto qa join questao q on q.id=qa.questao_id where assunto_id in (:assuntos_id) and q.tipo_questao = 'SUBJETIVA' GROUP BY q.id order by rand() limit 1;

```

:assuntos\_id is an array like [5,6]

how can make this??

Answer: 
In the past, the documentation explicitly explained this, reading in part:

> 
> In the examples you see that **you can use a type name and access an instance method name. You do not need to have an instance of the type**… *[emphasis mine]*
> 
> 
> 

This has been omitted in [the current documentation](https://msdn.microsoft.com/en-us/library/dn986596.aspx). However, the examples still make this clear. Code samples such as `Console.WriteLine(nameof(List<int>.Count)); // output: Count` and `Console.WriteLine(nameof(List<int>.Add)); // output: Add` show how to use `nameof` to obtain the `string` value with the name of an instance member of a class.

I.e. you should be able to write `nameof(ClientService.EndDate)` and have it work, contrary to your observation in the question that this would be *"not normally syntactically valid"*.

If you are having trouble with the syntax, please provide a good [Minimal, Complete, and Verifiable code example](https://stackoverflow.com/help/mcve) that reliably reproduces whatever error you're getting, and provide the *exact* text of the error message.
Great answer by @Peter Duniho.

In case of name clashes, you can also do the following:

```
ClientService clientservice;
var str = nameof(clientservice.EndDate);

```

Not efficient, but curious enough.