Serializable BindingList<T> with Remoting

Serializable BindingList<T> with Remoting

Old forum URL: forums.lhotka.net/forums/t/3560.aspx


daa posted on Tuesday, September 18, 2007

In tne CSLA there is a generic class named ExtendedBindingList<T> wich is the base class off all Entity collections. It is a very good idea but there is one great problem that i found. In remoting model in general just Interfaces are exposed to client. Exemple if i have an entity named MyEntity: IMyEntity the client will just know IMyEntity. And then we can not expose associated collection like this MyEntityCollection: ExtendedBindingList<MyEntity>. In that case we will be forced to expose MyEntity to client. Therefore we should expose the interface IMyEntityCollection and we should have MyEntityCollection: ExtendedBindingList<IMyEntity>,IMyEntityCollection. Another great problem due to the .NET Framework is that if we want to expose MyEntityCollection by remoting his base classe must be MarshalByRefObject but our class have already a base class: ExtendedBindingList<T> where T is my entity type.

Is there any one who know how to solve this problem?

RockfordLhotka replied on Tuesday, September 18, 2007

ExtendedBindingList is not intended as a base class for most business collections. You should use BusinessListBase instead. Read Chapter 7 for details.

ExtendedBindingList isn't really the base either. The base is BindingList<T>, from .NET itself. the CSLA .NET Version 2.1 Handbook covers the details on ExtendedBindingList. All it does is add an event to BindingList<T> to simplify one particular scenario.

Also, CSLA is not intended to allow you to create "anchored" objects that inherit from MRBO. It is designed to support mobile objects that move across the network as necessary. Only the data portal uses MRBOs. See chapters 1 and 4 for details.

It is hard to imagine why you'd want to expose a collection from a server, where that collection couldn't leave the server. That'd be like the old COM collections, and that was a nightmare for almost everyone.

daa replied on Tuesday, September 18, 2007

Thank a lot for your quick answer. I totally agree with you that i should use BusinessListBase to implement collection off business objects. Sorry for the error.

The only reason to expose collection from the server and Interface to client is to have an easy maintance. But while reading your post i thing that i have found the solution off my problem: i can expose directly to client collections like this: MyEntityCollection: BusinessListBase<MyEntityCollection, IMyEntity>
It's not a perfect solution because this solution oblige to deploy dll to client if i update my business entity collections implementation. If i'd expose only interface i just need to update server. That's why i wanted to expose collection from the server.

RockfordLhotka replied on Tuesday, September 18, 2007

Yes, CSLA requires that the business assembly be on the client machine. That's a core part of the architecture.

If you don't want to do that, then CSLA probably isn't for you.

But no one seriously considers exposing a collection from a server directly. If you make your collection an MBRO then every row and every property that is accessed from the client will require a call to the server. The performance of such a solution would be terrible. I made a lot of money fixing exactly this issue back in the days of COM (where people would expose collections from a server just like this).

The accepted alternative to the CSLA approach is to use services, where the "collection" is returned to the client as a blob of XML that is parsed into an array of dumb data objects (DTOs).

daa replied on Tuesday, September 18, 2007

I definitly find my question's answer with your help off course. I've tested to expose Buisiness Entity interfaces to client. For the collection i expose directly the assembly to client and now those collection aren't MBRO and every thing work fine. Client can create directly new business object collection without calling server or call Service from the server to retrieve a particular collection according to a criteria. Now i just have to test performance.

Thanks for all

Copyright (c) Marimer LLC