write xml and collection

Posts   
 
    
betux
User
Posts: 7
Joined: 22-May-2006
# Posted on: 30-Aug-2006 09:02:11   

Hello,

I use llblgen v1.0.2005.1 selfservicing.

I have two pbs ;

  1. I have a collection witch contain 2 entity linked.

I want to write an xml file witch contain all data of the two entity for an id.

i write a class ; public static MamJobsCollection jobsxml(string id) {

        MamJobsCollection jobs = new MamJobsCollection();
        IPredicateExpression filter = new PredicateExpression();
        RelationCollection rel = new RelationCollection();
        rel.Add(MamJobsEntity.Relations.MamJobsAffectationEntityUsingFicJobId);


        filter.Add(MamJobsFields.FicJobId == id);
        jobs.GetMulti(filter,0, null,rel);
        return jobs;
    }

and i call it like this :

protected void Button1_Click(object sender, EventArgs e) {

    StreamWriter writer = new StreamWriter("c:\\jobs.xml");
    string stringxml = string.Empty;
    fopxml.jobsxml("561").WriteXml(out stringxml);
    writer.Write(stringxml);
    writer.Close();


}

so it work, but i don't have the second entity.

i try to make two collection and put it in the stream but i have a pb of root nod.

StreamWriter writer = new StreamWriter("c:\jobs.xml"); string stringxml = string.Empty; fopxml.jobsxml("561").WriteXml(out stringxml); writer.Write(stringxml); fopxml.jobsaffxml("561").WriteXml(out stringxml); writer.Write(stringxml); writer.Close();

  1. I don't understand how to write a compact xml i think the documentation is not the same than options in visual studio. i've read this thread (http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=832&HighLight=1) but i need a concret exemple.

someone can help me ?

thanks.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 30-Aug-2006 16:08:51   

You have not used the relationCOllection in the fetch method. Please use the following GetMulti overload:

public bool GetMulti(
   IPredicate selectFilter,
   long maxNumberOfItemsToReturn,
   ISortExpression sortClauses,
   IRelationCollection relations

i try to make two collection and put it in the stream but i have a pb of root nod

What problem that you have? please elaborate.

  1. Please refer to the LLBLGen Pro manual, section "Writing / reading object hierarchies to / from XML"

found in the following path: "Using the generated code -> XML Support (serialization, de-serialization)"

betux
User
Posts: 7
Joined: 22-May-2006
# Posted on: 30-Aug-2006 17:56:37   

hello walaa,

thanks for the reply, you're right i miss my relation in getmulti() when i paste it. With the relation it doesn't work.

It's why i try to put two collection in the xml but i'have two root nod and it's no good.

i do this ;

protected void Button1_Click(object sender, EventArgs e) {

StreamWriter writer = new StreamWriter("c:\jobs.xml"); string stringxml = string.Empty; fopxml.collection1("561").WriteXml(out stringxml); writer.Write(stringxml); fopxml.collection2("561").WriteXml(out stringxml); writer.Write(stringxml); writer.Close(); }

the manual is my bible for a while but on this subject i don't understand parameters of .writeXml it's not like in the same than the manual, and i don't understand how to add all my data.

thanks for your help.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 31-Aug-2006 08:27:57   

I don't know what this is: fopxml.collection1("561").WriteXml(out stringxml); But simply if you have a collection with some entities inside all you need to do is:

StreamWriter writer = new StreamWriter("c:\\jobs.xml");
string stringxml = String.Empty;

yourCollection.WriteXml(out stringxml );

writer.Write(stringxml );
writer.Close();

betux
User
Posts: 7
Joined: 22-May-2006
# Posted on: 31-Aug-2006 09:35:30   

i thought the same thing but it didn't work.

to find an other way i would like to convert my collection in datatable, so i thought i will find .GetMultiAsDataTable and no.

my using are ;

.CollectionClasses; .EntityClasses; .FactoryClasses; .HelperClasses; .TypedListClasses; using SD.LLBLGen.Pro.ORMSupportClasses; .StoredProcedureCallerClasses; .MAMBO.DaoClasses; .MAMBO.RelationClasses; .MAMBO.ValidatorClasses;

i miss one ??

thanks

betux
User
Posts: 7
Joined: 22-May-2006
# Posted on: 31-Aug-2006 12:06:31   

i forgot to say for compact xml i write this : collection1.WriteXml(XmlFormatAspect.Compact | XmlFormatAspect.DatesInXmlDataType | XmlFormatAspect.MLTextInCDataBlocks, out stringxml);

and it works, but i always miss data of one entity in my collection

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 31-Aug-2006 15:42:04   

i thought the same thing but it didn't work

Please explain exactly what do you mean by it did not work. And if there is an exception or error please post the error text and the stack trace.

The GetMultiAsDataTable is a method available in any of the xxDao Classes. in v.1.0.2005.1 (selfservicing)