I'm building an editable root business object and following along with the csla 4 data access ebook and it's example of DataPortal_Create does *not* show overriden methods e.g.:
private void DataPortal_Create(int regionId)
{
...etc...
and when I copy them exactly I get the compiler error:
zEditableRoot.cs(236,21): warning CS0114: 'Test.Library.zEditableRoot.DataPortal_Create()' hides inherited member 'Csla.Core.BusinessBase.DataPortal_Create()'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.
Do I just use the "new private void DataPortal_Create()" signature instead? Does the ebook need to be updated with the new keyword added?
Also if I want to support both silverlight and wpf / asp.net mvc do I need to make two DataPortal_Create methods in every business object? One for Silverlight and one for the rest?
The method signatures for DataPortal_Create are different on .NET and Silverlight, because the SL one must be public and async.
If you are building your app to run in 1-tier or 2-tier deployments, so you expect the DataPortal_Create methods to run always on the client (.NET and SL) then yes, you need to implement the method using both signatures with either compiler directives (my preference) or partial classes.
The next revision of the Data Access ebook provides a direct example of this scenario - I just wrote that bit today actually.
I suspect the reason you are encountering the compiler issue is because of the SL base class, where the default virtual method is a method with a single parameter. The code in the version of the book you are using is for .NET only.
Interesting. Thank you for the information.
Can you explain what you mean by implementing the method using both signatures with compiler directives? (Do you mean the #If Silverlight directives, where both signatures are there just conditionally compiled for each directive?)
Rocky I'm trying to implement this as you suggested however now I'm getting:
'Csla.DataPortal' does not contain a definition for 'ProxyModes'
on compile.
Any chance that Ebook is coming out soon? :)
I really need an example.
Aside from that compiler error, from what I can determine what I need to do to support both SL and .net in my library is to make a DataPortal_Create with a runlocal attribute for .net then a static "New" method for SL like this:
public static void New(EventHandler<DataPortalResult<zEditableRoot>> callback)
{
DataPortal.BeginCreate<zEditableRoot>(callback, DataPortal.ProxyModes.LocalOnly);
}
However, you mentioned conditional compilation so would the above *not* call the .net DataPortal_Create method? If not then what is it calling.
Do any of the sample projects show this because I can't find any example of a local create method that supports both SL and .net in one project?
Found a sample that *might* be what I'm after but I don't trust any of the samples now that Johnny has said that the ProjectTracker is not meant to be used even though it's in the samples folder so I just want to confirm if the "SimpleApp" solution found in the silverlight samples is illustrating the correct way of doing things in the CustomerEdit class?
Rocky I'm trying to implement this as you suggested however now I'm getting:
'Csla.DataPortal' does not contain a definition for 'ProxyModes'
on compile.
Any chance that Ebook is coming out soon? :)
I really need an example.
The pre-release of the Data Access book that I put online yesterday includes a discussion of persistence for the editable root and editable root list stereotypes, and it includes factory methods for .NET and Silverlight - exactly the issue you are asking about.
Thanks Rocky, that updated ebook really helps. It's starting to come together. When I was just looking at the samples I was all kinds of confused and went in a lot of wrong directions.
Copyright (c) Marimer LLC