Generic class namespace restriction

I would like to know if (and if so, how) it is possible to define a namespace as a restriction parameter in a declaration of a universal class.

What I have:

namespace MyProject.Models.Entities <- Contains my classes for saving in db

namespace MyProject.Tests.BaseTest <- Obviously, I think

Now the declaration of my BaseTest class looks like this:

public class BaseTest<T>

This one BaseTestdoes a bit more (at the time of writing) than it removes all entities that were added to the database during testing. Therefore, usually I will have a testing class declared as:

public class MyEntityRepositoryTest : BaseTest<MyEntity>

What I would like to do is something similar to the following:

public class BaseTest<T> where T : <is of the MyProject.Models.Entities namespace>

, BaseEntity, , MyProject.Models.Entities, ;

public class BaseTest<T> where T : MyBaseEntity

... . ORM , , , .

, , ?

+5
3

.

internal, public. , ( InternalsVisibleTo). , (, / ).

+10

. .

+3

. , , .

+2

All Articles