BusinessListBase member variables not making jump to server (3.6.1)

BusinessListBase member variables not making jump to server (3.6.1)

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


TheEld posted on Wednesday, March 25, 2009

I have a standard BusinessListBase class that needs to carry some private data given to it by the client app in the factory method.  I then need this data during the DataPortal_Fetch() and DataPortal_Update() methods.  Something like below...

When using LocalPortal it all works (no big surprise).  But when using the WcfPortal the 2 Guids are always Guid.Empty (Default value for a Guid) in the DataPortal methods being executed remotley.  I'm sure this is something stupid that the book explains perfectly well, but I can't find it.

 

THANKS FOR YOUR HELP IN ADVANCE

 

[Serializable] public class SystemList : BusinessListBase<SystemList, System>
{
    private static Guid _UserUH;
    private static Guid _CompanyUH;

    public static SystemList GetSystemList(Guid UserUH, Guid CompanyUH, Guid UH)
    {
        _UserUH    = UserUH;
        _CompanyUH = CompanyUH;

        return DataPortal.Fetch<SystemList>(new SingleCriteria<SystemList, Guid>(UH));
    }

 

   private void DataPortal_Fetch(SingleCriteria<SystemList, Guid> Criteria) 

   {

          Access to _UserUH & _CompanyUH

   }

 

    protected override void DataPortal_Update()
    {
       Access to _UserUH & _CompanyUH

    }

}

 

JoeFallon1 replied on Wednesday, March 25, 2009

The only way to get data to the other side of the dataportal is to include it in the Criteria object. You are using SingleCriteria for convenience but in this case you need to build your own SystemCriteria class that takes 3 values in its constructor:
guid
userUH
companyUH

Then you pass an instance of your SystemCriteria instead of SingleCriteria. Be sure to adjust the signture of Fetch to expect the new type. Then you will have all 3 values available on the other side of the portal.

Joe

PS - A command Object passes itself through the portal so defining fields on it works for both sides of the portal. But that is a unique type and not the norm.

TheEld replied on Thursday, March 26, 2009

Thanks for your answer.  I can see where that would work for the Fetch.  But I also need the data available on the other side in DataPortal_Update() which takes no paramaters at all.

 

rsbaker0 replied on Thursday, March 26, 2009

Again, why are these two fields declared as static? 

If they were non-static member variables, they should be serialized across with your update (at least until you get into scenarios that require managed properties or your own serialization-assistance code like Silverlight).

 

rsbaker0 replied on Wednesday, March 25, 2009

I'd think the problem in this particular case is that the member variables in question are declared "static". I don't think static data ever gets serialized with an object instance.

 

Copyright (c) Marimer LLC