Updated sample applications...

Updated sample applications...

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


Ryan M posted on Wednesday, January 19, 2011

In the models for in both the SLDemo and CslaMvvmSl sample applications csla.DataPortalClient.LocalProxy<...> is used in the DataPortal_Insert/Update/Fetch/etc methods.  This seems to have changed in more recent versions, such that many of those methods are no longer available for override and those methods that are (still available) do don't take any parameters.

Are there any updated examples for newer versions of CSLA?  I'm using 4.0.

Thank you,

Ryan

RockfordLhotka replied on Wednesday, January 19, 2011

There's a difference between the way you write the DataPortal_XYZ methods in .NET and SL.

In .NET the DataPortal_XYZ create/fetch/delete methods take whatever parameter type you want to pass - as long as the type is serializable. The insert/update/deleteself methods don't accept any parameters and are virtual. The create method is also virtual, but only if you use the default implementation with no parameters.

In SL the DataPortal_XYZ methods all require a callback parameter, because the assumption is that most of these methods will be invoking remote services. Those invocations must be asynchronous, therefore the DataPortal_XYZ methods must be asynchronous, therefore they must accept a callback.

In SL the DataPortal_XYZ create/fetch/delete methods take whatever additional parameter type you want to pass - as long as the type is serializable. The insert/update/deleteself methods don't accept additional parameters and are virtual. The create method is also virtual, but only if you use the default implementation with only the callback parameter.

This is all covered in a lot of detail in the upcoming Using CSLA 4: Data Access ebook, part of the Using CSLA 4 ebook series.

All the samples in the CSLA 4 version 4.1 Samples download should be current and should work, so please check them out.

Ryan M replied on Wednesday, January 19, 2011

OK, thanks.  That makes sense.  I want to use the same model in WPF and SL applications, so I had added the class files as links in visual studio. 

I'll request that we get the ebooks.  In the mean time I'm assuming the best way to use essentially the same model for both environments is to create the data access on the non-SL side and access those methods asynchronously via the equivalent SL methods.  Or is there a better way?

Thanks,

Ryan

Ryan M replied on Wednesday, January 19, 2011

...or just always put the model in a silverlight project...

RockfordLhotka replied on Wednesday, January 19, 2011

I generally use file links and compiler directives. The code in the Creating Business Objects and Data Access ebooks shows how to use compiler directives as appropriate.

Also the \Net\cs\SimpleNTier sample app demonstrates how to make a business model that is shared between .NET, SL and WP7.

Copyright (c) Marimer LLC