I have a opteration that needs to run on three types of EntitySets; however, the data for each type is the same. Linq-to-SQL is creating these three types to match up with a few between, “tween” tables in my database.
Is there a way to work with generic EntitySet types like I’ve got them below?
private EntitySet<T> GetClientHorizontal(EntitySet<T> clientHorizontal) {}
It is to solve the redundant issue like below.
private EntitySet<LeafHorizontal>
GetClientLeafHorizontal(EntitySet<LeafHorizontal> clientLeafHorizontal) { }
private EntitySet<BayHorizontal>
GetClientBayHorizontal(EntitySet<BayHorizontal> clientBayHorizontal) { }
private EntitySet<SideliteHorizontal>
GetClientSideliteHorizontal(
EntitySet<SideliteHorizontal> clientSideliteHorizontal) { }
If you are saying that these three classes are almost the same – then you can create an interface or base class with common members:
Then you need to inherit LeafHorizontal, BayHorizontal and SideliteHorizontal classes from this interface:
After that you can create generic method: