I am wondering whether I can use the this
keyword inside a C# lambda, although actually I know that I can but I want to make sure that this isn\'t a bad th
It is absolutelly fine to use this
in lambdas, but there is some stuff you should keep in mind:
this
will be kept in memory until the lambda is not used anymorethis
" outside your class, then you will not face problemsthis
" outside your class, then you should remember, that your class will not be collected by the GC
until there are references to the lambda left.And related to your use-case, you should keep in mind that the Repository
instance will never be collected by the GC
until people it created are in use.