Workaround for C# generic attribute limitation

前端 未结 3 1990
遇见更好的自我
遇见更好的自我 2021-01-07 23:52

As discussed here, C# doesn\'t support generic attribute declaration. So, I\'m not allowed to do something like:

[Audit (UserAction.Update)]
publ         


        
3条回答
  •  难免孤独
    2021-01-08 00:11

    You have at least these three possibilities:

    1. You could use reflection to call LoadById
    2. You could create an expression tree that calls LoadById
    3. You could provide a LoadById method in your repository that is not generic.

提交回复
热议问题