Please first read the following thread:
Circular reference between Assemblies in C# and Visual Studio 2005
Implementing interfaces is solving my problem but not fulfilling my target.
My target is to work only with BO-layer/assembly from the UI layer/Assembly. So that I can maintain a clean layer-to-layer reference.
Coz I don’t want a reference to be added both for BO-layer/assembly and ORMapper-layer/assembly in the UI-layer/assembly.
I only want to work with BO-layer/assembly from within UI-layer/assembly.
Meanwhile someone suggested me that, it can only be possible with using Reflection, not DI. Is that true?
If you really insist on hiding the ORM layer behind your BO layer, then Dependency Injection should still be able to help you out. Note that you will not be able to get away from referencing the DI library from your UI thread though, because that’ll be where your business objects will come from then.
Approach:
UserobjectsUserobject a constructor that takes an instance of the population interface to load data fromThen when you need a
Userobject, you ask the DI library to create it, and the DI library will construct theUserand give it a reference to the ORM implementation. You’ll have to inject some properties into the DI call as well for the ‘username’ and ‘password’ to be able to fully populate it with values.Note that this is not exactly what DI was invented for… application code is really supposed to deal with ORM directly to create/read/update/delete business objects.