I’m trying to use IoC on small project for which I use one commercional ORM.
There is collection of ‘User’ Entites on my Entity ‘Project’. When I pass an interface to the method, I’m unable to add th eobject to the collection of ‘User’ entities, because it is represented by some ORM EntityCollection class.
Example:
//'this' is a partial class to the modeled Entity<int>
public void AddToCollection(IUser user)
{
this.Users.Add(user); //this.Users is type of EntityCollection.
}
I see the two possibilities here and I don’t know which one is the best practice.
- Change the EntityCollection to IEnumerable (which is not possible)
- Cast IUser to User
Or may be I’m going completely wrong way wiht IoC, what is the best practice here?
as for me, it’s not a good to use interface for entities. prefer base class instead.
Best regard