[SOLVED/FIXED]Load XML offline

Posts   
 
    
WMS
User
Posts: 11
Joined: 26-May-2004
# Posted on: 29-May-2004 18:54:26   

I am using LLBL Pro in an offline application(without SQL server connection) the schema is each customers have several OverseasNetworks. So the generated XML file is like:

<Entity CustId="Customer1" Assembly="..." Type="DAL.EntityClasses.CustomerEntity"> ....... <EntityCollectionReference PropertyName="OverseasNetwork"> <OverseasNetwork Assembly="" Type=""> <Entities> <Entity Id="115..

    ......
</OverseasNetwork>
  </EntityCollectionReference>

</Entity>

When I read the xml using readXML method, exception is thrown because there is no database connection. But if I delete these keypersonnel nodes in the xml, the reading is ok.

How can I avoid this database connection? because all the data of keypersonnel are inside of the xml file. so I think it should have a way to avoid database connection, right? stuck_out_tongue_winking_eye .

Thanks in advance

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 29-May-2004 19:15:49   

I'll look into it, there shouldn't be a database call when calling ReadXml().

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 30-May-2004 12:14:57   

I've tried this: StreamReader reader = new StreamReader("chopsFilled.xml"); MyCustomerEntity customerChopsFromXml = new MyCustomerEntity(); string xml= reader.ReadToEnd(); reader.Close(); customerChopsFromXml.ReadXml(xml);

and it works ok, I've altered the connection string to make connection with a bogus machine, and no problems arised, no delays no errors.

PS: this is adapter. I'll now test selfservicing.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 30-May-2004 12:39:20   

With selfservicing I get indeed a timeout error when a collection is restored. I think lazy loading is entered, while this shouldn't be the case. I'll look into it.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 30-May-2004 12:46:37   

Found it. The templates do not check for base.Deserializing == true. This means that a fetch of the entities is performed, while this is unnecessary because the collection will be restored through deserialization.

Will fix this.

Thread moved to Bugs/issues.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 30-May-2004 13:26:39   

The hotfix for this is now available in the form of a template set update. See the template sets section in the customer area.

Frans Bouma | Lead developer LLBLGen Pro
WMS
User
Posts: 11
Joined: 26-May-2004
# Posted on: 31-May-2004 13:16:23   

Otis wrote:

The hotfix for this is now available in the form of a template set update. See the template sets section in the customer area.

Thank you so much for the quick action. I think I bought good product and service. simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 31-May-2004 13:31:58   

simple_smile

If you run into problems with the fixed templates, please let me know simple_smile

Frans Bouma | Lead developer LLBLGen Pro
WMS
User
Posts: 11
Joined: 26-May-2004
# Posted on: 01-Jun-2004 07:57:36   

Otis wrote:

simple_smile

If you run into problems with the fixed templates, please let me know simple_smile

Everything is working well, except that the propety of obj: EntityFactoryToUse

if there is a node in XML like this: <EntityFactoryToUse Assembly = Unknown" the a error message will pop up when read this xml file offline, saying the obj is not a instance in the entity2collection method( I forget the exact method. maybe not this one).

Currently what i did is to remove this node in xml before saving it to disk.

hope you can take a look at it.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 01-Jun-2004 08:23:22   

That means that the entityfactory is null. I'll check it out.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 01-Jun-2004 10:49:00   

I can't reproduce it here.

I tested the following: (all selfservicing) - an OrderCollection with solely Order objects. Written to XML to disk, read back in a new OrderCollection. Worked - same as above, but now I set EntityFactoryToUse to null before I generated the XML. It gave the same tags as you had, worked. - a Customer entity with Orders collection filled. Written to XML and back, worked.

I'm curious to know what you do exactly when you fetch the objects and write them to XML. Is it a single entity, or a collection? (important), do you set any properties to null before you save it to XML?

Frans Bouma | Lead developer LLBLGen Pro
WMS
User
Posts: 11
Joined: 26-May-2004
# Posted on: 01-Jun-2004 20:19:52   

Otis wrote:

I can't reproduce it here.

I tested the following: (all selfservicing) - an OrderCollection with solely Order objects. Written to XML to disk, read back in a new OrderCollection. Worked - same as above, but now I set EntityFactoryToUse to null before I generated the XML. It gave the same tags as you had, worked. - a Customer entity with Orders collection filled. Written to XML and back, worked.

I'm curious to know what you do exactly when you fetch the objects and write them to XML. Is it a single entity, or a collection? (important), do you set any properties to null before you save it to XML?

it is a collection of customer, which has a collection of networks. First I write xml of the customer collection online, the EntityFactoryToUse will be filled by value. then I read xml of customer collection offline and save it offline. EntityFactoryToUse will have unknow value. then next time I read xml of customer collection offline. the error msg comes.

The problem resides on saving the customer offline, which don't have the value of EntityFactoryToUse.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 03-Jun-2004 11:11:48   

I wonder why the entityfactorytouse is suddenly null, as the class is part of the generated code. So when you read the XML offline, you should have the entity factory class available, so when you then again write it offline, EntityFactoryToUse should have a value, not null... could you check for me if the EntityFactoryToUse property is null AFTER you've read the XML offline?

Frans Bouma | Lead developer LLBLGen Pro
WMS
User
Posts: 11
Joined: 26-May-2004
# Posted on: 05-Jun-2004 10:03:37   

Otis wrote:

I wonder why the entityfactorytouse is suddenly null, as the class is part of the generated code. So when you read the XML offline, you should have the entity factory class available, so when you then again write it offline, EntityFactoryToUse should have a value, not null... could you check for me if the EntityFactoryToUse property is null AFTER you've read the XML offline?

Hi Otis, When first I generate it online, EntityFactoryToUse is filled with value. but when I read it offline, and store them back offline, EntityFactoryToUse becomes null. I tried this. so I have to remove all the EntityFactoryToUse nodes when I store xml offline.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 05-Jun-2004 11:10:53   

WMS wrote:

Otis wrote:

I wonder why the entityfactorytouse is suddenly null, as the class is part of the generated code. So when you read the XML offline, you should have the entity factory class available, so when you then again write it offline, EntityFactoryToUse should have a value, not null... could you check for me if the EntityFactoryToUse property is null AFTER you've read the XML offline?

Hi Otis, When first I generate it online, EntityFactoryToUse is filled with value. but when I read it offline, and store them back offline, EntityFactoryToUse becomes null. I tried this. so I have to remove all the EntityFactoryToUse nodes when I store xml offline.

The thing in italics should not happen. I'll check it out if I can reproduce it here...

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 08-Jun-2004 12:15:04   

I can't reproduce this.

What I did was this:


public void SerializationTest()
{
    StreamWriter writer = new StreamWriter("customer.xml");
    CustomerEntity customer = new CustomerEntity("BLONP");
    OrderCollection orders = customer.Orders;
    string xml = string.Empty;
    customer.WriteXml(out xml);
    writer.Write(xml);
    writer.Close();
}

public void DeserializationTest()
{
    StreamReader reader = new StreamReader("customer.xml");
    string customerXml = reader.ReadToEnd();
    CustomerEntity customerFromXml = new CustomerEntity();
    customerFromXml.ReadXml(customerXml);
    reader.Close();

    // write it back to a different file.
    StreamWriter writer = new StreamWriter("customer2.xml");
    string xml = string.Empty;
    customerFromXml.WriteXml(out xml);
    writer.Write(xml);
    writer.Close();
}

//...
// call the 2 testroutines:
tester.SerializationTest();
tester.DeserializationTest();

Checking both xml files, I can only conclude that they all contain the right xml and load correctly.

Even if I make the entityfactorytouse null, it works. So I have the feeling the code on client and server aren't in sync with eachother: you use an older version of runtimes and/or generated code on client or server than the other process (so newer on server, older on client or vice versa). Could you check that for me, please?

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 05-Jul-2004 11:45:33   

Issue was re-opened and a fix to the ReadXml method is now available in a hotfix for the runtime libraries. Could you please test if this fix is also fixing your problem?

Frans Bouma | Lead developer LLBLGen Pro