开发者

How to use business objects in silverlight from existing project

We have a really large solution with a custom data access and business logic layer. Currently we have a Windows Forms UI as well as an aspx web interface.

We now wish to repla开发者_Go百科ce the aspx front end with a Silverlight project. We would as first prize like to use the existing business logic layer (business objects) which subsequently calls our custom Data Layer to retrieve and update data. These are all .net 3.5 class library projects.

Is it going to be possible to use these projects? Or am I going to need to rework the data access layer by using something like EF4? Would using RIA services to access these objects be a solution?

If anyone has any ideas how to achieve this or experience in doing this please let me know.


The big question is, are you porting the UI design to Silverlight (with may be a little whiz-bang where possible) or are you redesigning the UI?

If its a redesign then forget your old business objects. Like it or not the old business objects will be oriented to toward the old UI especially its behaviour. A new model based on EF4 would be the convential approach here.

If though your are porting the UI fundementally the same but with a Silverlight spin then you may be able to re-use some business objects via WCF. However that its like doubtful as well.


a SL application can only reference a SL classLibrary or have web/service referencers.

In your case I would create a WCF service library to use as a bridge and I would expose my business entities from that layer.

thanks to the partial keyword you do not have to move your entities definition to the WCF class library, you could simply define them again as partial in the DataContracts...

... of course getting into details it depends on the way your entities are done, if you have common classes or interfaces and so on but it's surely possible to do what you need without rewriting completely your entities...


Davide has a point. You could expose them as datacontracts and let them be generated on the client.

If you need extra client side logic or properties then what you could do is add the classes in the library as a link in a new SL library. Then as long as they are in the same namespace as they are on the server (you can force this by setting the default namespace on your SL library), svcutil will detect them when generating your proxy and will use them.

Defining them as partial, would then make them extendable on both side with unique logic or properties.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜