Using NHibernate and no reference to its assembly in the client application
We have a multi-tier application using CSLA Business Objects and NHibernate ORM. In our business objects, we store the collection data items as ICollection<T>
, and in our object mapping files, we define them as <set>
s.
Since NHibernate uses its concrete types to retrieve these collections, we have a problem when these collections reach the client because we are not referencing the NHibernate assembly in the client application (and we do not want to modify it).
Is there a way to solve this problem or somehow force NHibernate to use the .net collection type or our own collection type without implementing any NHibernate collection type interface?
Thanks Advance,
Yaron.
NHibernate needs its own collection implementations to manage persistence states. Thus, you cannot change the behavior of NHibernates.
We are using WCF, it converts collections to arrays or lists when serializing. If your framework does not do this, then you need to transform the objects before sending to the client.
Your best bet is to use the DTO (Data Transfer Object) model. You need to copy all data from the business model to the DTO model.
If you don't like having a DTO model, I think you need to exchange collections. Write a method to exchange NH collections with .NET framework collections, e.g. using reflection.
Or - you live with a NHibernate reference on the client.
a source to share