editable business list base problem( correct usage?)

editable business list base problem( correct usage?)

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


kam_csla posted on Wednesday, March 30, 2011

Business Layer
class A<BusinessBase>
{
    public string var1="";
    public string var2="";
    public string VarMain ="";
    public AList objAList = new AList();
    
}

class AList<EditableBusinessListBase>
{
   
}

Presentation Layer

A mainObj = new A();
mainObj.VarMain  = "COMPANY_ID1";

A tempMainObj;

foreach(A ref in PresentationEquivalentAList)
{
    tempMainObj = new A();
    tempMainObj.var1="Employee"+i;
    tempMainObj.var2 ="EmployeeName"+i;
    mainObj.objAList.Add(tempMainObj);
    i++;
}

mainObj.Save();

Basically am trying to save multiple employees using the same list object. what i have observed is the above didn't work if i use BusinessListBase instead of EditableBusinessListBase.

Save Method in Business Layer of A

SaveA()
{
      /*initialize data access layer
    the entire object is sent as xml clob data type to backend oracle database.
    using this.ToXML()
   
    which creates an xml like
    <CSLA_OBJECT>
    <A>
    <varMain>value</varMain>
    ##########################
    </A>
    </CSLA_OBJECT>
    */
}   
i expected the part denoted in #s to have the objAList which will have each employee...
But what it show in the xml is just a plan string representation of the objAList object i.e it simply says that listobject name...

But the same process if i add extra  SubA<BusinessBase>, SubAList<BusinessListBase> and add the SubAlList object as a property in A<BusinessBase> and eventually when i say toxml() it is now showing the clear xml including the child items under the list object as well..

hope the above is clear... please explain where am doing wrong... is this the correct approcah? thanks in advance...

RockfordLhotka replied on Thursday, March 31, 2011

How does your ToXML method work?

I suspect it uses the XmlSerializer or DataContractSerializer. Neither of these work against CSLA objects - that has been discussed many times on the forum, and is in the FAQ (http://www.lhotka.net/cslanet/faq/XmlServicesFaq.ashx), and is covered in the upcoming Using CSLA 4: Data Portal Configuration ebook.

Copyright (c) Marimer LLC