Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# project-wide using alias directives

Tags:

c#

C# has a feature called Using alias directives. They allows you do make an alias of a type like this:

using CustomerId = MyComp.MyProject.Core.EntityKey<Customer, int>;

This feature however only works on a per-file basis. I'm looking for a way -any way- to do this project-wide or even solution-wide.

The reason I want to do this is because I want to remove the verbosity of writing things like EntityKey<Customer, int>, EntityKey<Order, long>, etc. I like to prevent having to define those aliasses in each file. The EntityKey<TEntity, TKey> is a struct, so I can't create derived classes.

like image 291
John Zoo Avatar asked Nov 23 '12 09:11

John Zoo


1 Answers

No, that does not exist. Aliases are strictly per-file.

like image 197
Marc Gravell Avatar answered Sep 21 '22 18:09

Marc Gravell