This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I use the last version of Lightspeed 3.11 and I want to ask, if is possible to model the entity implementing an interface? What I'm fingting for? I use an IoC/DI and when I pass an interface to the method, I'm unable to add it to a EntityCollection, of course. Example:
I see the two possibilities here and I don't know which one is the best practice. Or may be I'm going completely wrong way wiht IoC, what is the best practice here? Thank you |
|
|
I am guessing you are trying to avoid dealing in concrete types to support loose coupling. So on that assumption given the method you have defined if there is more than one entity implementing an IUser you would at some point have to determine what you are dealing with to decide which entity collection to apply it to at which point you can cast it back to the concrete type. So option 2 is the approach you are going to need to take here. There is nothing particularly wrong with what you are trying to do but there is a mismatch when you need to deal in terms of concrete types since an IUser is not necessarily an Entity (which EntityCollection or UnitOfWork.Add deal in) so at that point you have to cast back to concrete types where they have an Entity base.
|
|