ReadXML and PrefetchPaths

Posts   
 
    
jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 23-Nov-2004 19:49:39   

Hi, Frans. I'm implementing an Adapter system via web services and am running into trouble using ReadXML when Prefetch Paths are used.

First, here's the code for the WebMethod in question


        Dim records As HelperClasses.EntityCollection
        Dim adapter As New LLBL.DatabaseSpecific.DataAccessAdapter
        Dim timeRecord As New EntityClasses.TimeRecordEntity
        Dim xmlString As String
        Dim path As PrefetchPath2

            path = New PrefetchPath2(EntityType.TimeRecordEntity)
            path.Add(EntityClasses.TimeRecordEntity.PrefetchPathProject).SubPath.Add(EntityClasses.ProjectEntity.PrefetchPathClient)

            records = New HelperClasses.EntityCollection(New FactoryClasses.TimeRecordEntityFactory)

            adapter.FetchEntityCollection(records, Nothing, path)

            records.WriteXml(xmlString)

            Return xmlString

And here's the exception message and stacktrace:


Value cannot be null.
Parameter name: value
   at System.Collections.CollectionBase.OnValidate(Object value)
   at System.Collections.CollectionBase.System.Collections.IList.Add(Object value)
   at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2.Add(IEntity2 entityToAdd)
   at SD.LLBLGen.Pro.ORMSupportClasses.XmlHelper.SetReadReferences(ArrayList nodeEntityReferences, Hashtable processedObjectIDs)
   at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2.ReadXml(XmlNode node)
   at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2.ReadXml(String xmlData)
   at JGG.Timesheet.UI.WinForms.frmManager2.Init() in C:\Documents and Settings\Jeff\My Documents\Visual Studio Projects\Timesheet\Timesheet\JGG.Timesheet.UI.WinForms\frmManager2.vb:line 274

The exception occurs at the .ReadXML call on the client:


            _service = New TimesheetService.Service1
            _records = New HelperClasses.EntityCollection(New FactoryClasses.TimeRecordEntityFactory)
            recordsXML = _service.GetRecords
            _records.ReadXml(recordsXML)

If I pull the prefetch path out the exception does not occur. Any thoughts?

Jeff...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 23-Nov-2004 20:33:56   

Strange... the entity re-instantiation doesn't seem to work or something (and returns null). Are you sure the type of the entity is loadable and available in the assembly specified in the xml tag? (the project entity I guess)

Frans Bouma | Lead developer LLBLGen Pro
jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 23-Nov-2004 20:46:37   

Yes, because I'm able to fetch and instantiate the related "Project" and "Client" entities independent of the TimeRecord entity from the client.

I thought that perhaps the XML string was getting truncated or something, but I was able to verify that the start and end tags are present in the XML string. Here's the XML that the .ReadXML() method is reading in:


"<EntityCollection Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.HelperClasses.EntityCollection"><Entities><TimeRecordEntity IDTimeRecord="10" Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.EntityClasses.TimeRecordEntity"><ConcurrencyPredicateFactory Assembly="Unknown" /><ObjectID Type="System.Guid">348df118-2501-4f75-bf4f-dd66b0388a7d</ObjectID><FieldsCustomPropertiesOfType Type="System.Collections.Hashtable">System.Collections.Hashtable</FieldsCustomPropertiesOfType><Validator Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.ValidatorClasses.TimeRecordValidator" /><IsNew Type="System.Boolean">False</IsNew><EntityValidator Assembly="Unknown" /><Fields><IDTimeRecord><CurrentValue Type="System.Int32">10</CurrentValue><DbValue Type="System.Int32">10</DbValue><IsChanged Type="System.Boolean">False</IsChanged
><IsNull Type="System.Boolean">False</IsNull></IDTimeRecord><IDProject><CurrentValue Type="System.Int32">1</CurrentValue><DbValue Type="System.Int32">1</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></IDProject><BeginDT><CurrentValue Type="System.DateTime">632340789896730000</CurrentValue><DbValue Type="System.DateTime">632340789896730000</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></BeginDT><EndDT><CurrentValue Type="System.DateTime">632340825890000000</CurrentValue><DbValue Type="System.DateTime">632340825890000000</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></EndDT><Comment><CurrentValue Type="System.String">Test</CurrentValue><DbValue Type="System.String">Test</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></Comment></Fields><EntityReference PropertyName="Project"><ProjectEntity I
DProject="1" Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.EntityClasses.ProjectEntity"><EntityCollectionReference PropertyName="TimeRecord"><TimeRecord Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.HelperClasses.EntityCollection"><Entities><ProcessedObjectReference ObjectID="348df118-2501-4f75-bf4f-dd66b0388a7d" /><TimeRecordEntity IDTimeRecord="14" Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.EntityClasses.TimeRecordEntity"><ConcurrencyPredicateFactory Assembly="Unknown" /><ObjectID Type="System.Guid">420d98dd-ef90-4733-8e79-032844a862c8</ObjectID><FieldsCustomPropertiesOfType Type="System.Collections.Hashtable">System.Collections.Hashtable</FieldsCustomPropertiesOfType><Validator Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.Va
lidatorClasses.TimeRecordValidator" /><IsNew Type="System.Boolean">False</IsNew><EntityValidator Assembly="Unknown" /><Fields><IDTimeRecord><CurrentValue Type="System.Int32">14</CurrentValue><DbValue Type="System.Int32">14</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></IDTimeRecord><IDProject><CurrentValue Type="System.Int32">1</CurrentValue><DbValue Type="System.Int32">1</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></IDProject><BeginDT><CurrentValue Type="System.DateTime">632340822831300000</CurrentValue><DbValue Type="System.DateTime">632340822831300000</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></BeginDT><EndDT><CurrentValue Type="System.DateTime">632340822831300000</CurrentValue><DbValue Type="System.DateTime">632340822831300000</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></E
ndDT><Comment><CurrentValue Type="System.String">Test 3</CurrentValue><DbValue Type="System.String">Test 3</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></Comment></Fields><EntityReference PropertyName="Project"><ProcessedObjectReference ObjectID="0595354e-1713-447c-86a8-69988540f4cb" /></EntityReference><LLBLGenProEntityName Type="System.String">TimeRecordEntity</LLBLGenProEntityName><CustomPropertiesOfType Type="System.Collections.Hashtable">System.Collections.Hashtable</CustomPropertiesOfType><IsDirty Type="System.Boolean">False</IsDirty><EntityState Type="SD.LLBLGen.Pro.ORMSupportClasses.EntityState">Fetched</EntityState><SavedFieldSets /></TimeRecordEntity><TimeRecordEntity IDTimeRecord="15" Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.EntityClasses.TimeRecordEntity"><ConcurrencyPredicateFactory Assembly="Unknown" /><ObjectID Type="System.Guid">4bb4865f-9cf7-4cab-aa52-dda25deb93
93</ObjectID><FieldsCustomPropertiesOfType Type="System.Collections.Hashtable">System.Collections.Hashtable</FieldsCustomPropertiesOfType><Validator Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.ValidatorClasses.TimeRecordValidator" /><IsNew Type="System.Boolean">False</IsNew><EntityValidator Assembly="Unknown" /><Fields><IDTimeRecord><CurrentValue Type="System.Int32">15</CurrentValue><DbValue Type="System.Int32">15</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></IDTimeRecord><IDProject><CurrentValue Type="System.Int32">1</CurrentValue><DbValue Type="System.Int32">1</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></IDProject><BeginDT><CurrentValue Type="System.DateTime">632340847535130000</CurrentValue><DbValue Type="System.DateTime">632340847535130000</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System
.Boolean">False</IsNull></BeginDT><EndDT><CurrentValue Type="System.DateTime">632340847535230000</CurrentValue><DbValue Type="System.DateTime">632340847535230000</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></EndDT><Comment><CurrentValue Type="System.String">Tester 2</CurrentValue><DbValue Type="System.String">Tester 2</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></Comment></Fields><EntityReference PropertyName="Project"><ProcessedObjectReference ObjectID="0595354e-1713-447c-86a8-69988540f4cb" /></EntityReference><LLBLGenProEntityName Type="System.String">TimeRecordEntity</LLBLGenProEntityName><CustomPropertiesOfType Type="System.Collections.Hashtable">System.Collections.Hashtable</CustomPropertiesOfType><IsDirty Type="System.Boolean">False</IsDirty><EntityState Type="SD.LLBLGen.Pro.ORMSupportClasses.EntityState">Fetched</EntityState><SavedFieldSets /></TimeRecordEntity><TimeRecordEntity IDTimeRe
cord="16" Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.EntityClasses.TimeRecordEntity"><ConcurrencyPredicateFactory Assembly="Unknown" /><ObjectID Type="System.Guid">9fbc122c-b3b7-425a-bd27-cf3a3852c88d</ObjectID><FieldsCustomPropertiesOfType Type="System.Collections.Hashtable">System.Collections.Hashtable</FieldsCustomPropertiesOfType><Validator Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.ValidatorClasses.TimeRecordValidator" /><IsNew Type="System.Boolean">False</IsNew><EntityValidator Assembly="Unknown" /><Fields><IDTimeRecord><CurrentValue Type="System.Int32">16</CurrentValue><DbValue Type="System.Int32">16</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></IDTimeRecord><IDProject><CurrentValue Type="System.Int32">1</CurrentValue><DbValue Type="System.Int32">1</DbValue><IsChanged Type="System.Boolean">False</IsC
hanged><IsNull Type="System.Boolean">False</IsNull></IDProject><BeginDT><CurrentValue Type="System.DateTime">632346867000000000</CurrentValue><DbValue Type="System.DateTime">632346867000000000</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></BeginDT><EndDT><CurrentValue Type="System.DateTime">632347011000000000</CurrentValue><DbValue Type="System.DateTime">632347011000000000</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></EndDT><Comment><CurrentValue Type="System.String">&lt;Enter Comment Here&gt;</CurrentValue><DbValue Type="System.String">&lt;Enter Comment Here&gt;</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></Comment></Fields><EntityReference PropertyName="Project"><ProcessedObjectReference ObjectID="0595354e-1713-447c-86a8-69988540f4cb" /></EntityReference><LLBLGenProEntityName Type="System.String">TimeRecordEntity</LLBLGenProEntityName>
<CustomPropertiesOfType Type="System.Collections.Hashtable">System.Collections.Hashtable</CustomPropertiesOfType><IsDirty Type="System.Boolean">False</IsDirty><EntityState Type="SD.LLBLGen.Pro.ORMSupportClasses.EntityState">Fetched</EntityState><SavedFieldSets /></TimeRecordEntity></Entities><DoNotPerformAddIfPresent Type="System.Boolean">True</DoNotPerformAddIfPresent><AllowNew Type="System.Boolean">True</AllowNew><Count Type="System.Int32">4</Count><EntityFactoryToUse Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.FactoryClasses.TimeRecordEntityFactory" /><SupportsSorting Type="System.Boolean">False</SupportsSorting><SupportsSearching Type="System.Boolean">True</SupportsSearching><Validator Assembly="Unknown" /><SupportsChangeNotification Type="System.Boolean">True</SupportsChangeNotification><AllowRemove Type="System.Boolean">False</AllowRemove><IsReadOnly Type="System.Boolean">False</IsReadOnly><AllowEdit Type="System.Boolean">True</Allo
wEdit></TimeRecord></EntityCollectionReference><ConcurrencyPredicateFactory Assembly="Unknown" /><ObjectID Type="System.Guid">0595354e-1713-447c-86a8-69988540f4cb</ObjectID><FieldsCustomPropertiesOfType Type="System.Collections.Hashtable">System.Collections.Hashtable</FieldsCustomPropertiesOfType><Validator Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.ValidatorClasses.ProjectValidator" /><IsNew Type="System.Boolean">False</IsNew><EntityReference PropertyName="Client"><ClientEntity IDClient="1" Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.EntityClasses.ClientEntity"><ConcurrencyPredicateFactory Assembly="Unknown" /><ObjectID Type="System.Guid">68dca2df-004a-4017-9c5b-baad7010e204</ObjectID><FieldsCustomPropertiesOfType Type="System.Collections.Hashtable">System.Collections.Hashtable</FieldsCustomPropertiesOfType><Validator Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.
21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.ValidatorClasses.ClientValidator" /><IsNew Type="System.Boolean">False</IsNew><EntityValidator Assembly="Unknown" /><Fields><IDClient><CurrentValue Type="System.Int32">1</CurrentValue><DbValue Type="System.Int32">1</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></IDClient><Name><CurrentValue Type="System.String">Herzog</CurrentValue><DbValue Type="System.String">Herzog</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></Name></Fields><EntityCollectionReference PropertyName="Project"><Project Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.HelperClasses.EntityCollection"><Entities><ProcessedObjectReference ObjectID="0595354e-1713-447c-86a8-69988540f4cb" /></Entities><DoNotPerformAddIfPresent Type="System.Boolean">True</DoNotPerformAddIfPresent><AllowNew Type="System.B
oolean">True</AllowNew><Count Type="System.Int32">1</Count><EntityFactoryToUse Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.FactoryClasses.ProjectEntityFactory" /><SupportsSorting Type="System.Boolean">False</SupportsSorting><SupportsSearching Type="System.Boolean">True</SupportsSearching><Validator Assembly="Unknown" /><SupportsChangeNotification Type="System.Boolean">True</SupportsChangeNotification><AllowRemove Type="System.Boolean">False</AllowRemove><IsReadOnly Type="System.Boolean">False</IsReadOnly><AllowEdit Type="System.Boolean">True</AllowEdit></Project></EntityCollectionReference><LLBLGenProEntityName Type="System.String">ClientEntity</LLBLGenProEntityName><CustomPropertiesOfType Type="System.Collections.Hashtable">System.Collections.Hashtable</CustomPropertiesOfType><IsDirty Type="System.Boolean">False</IsDirty><EntityState Type="SD.LLBLGen.Pro.ORMSupportClasses.EntityState">Fetched</EntityState><SavedFieldSets /></ClientEntity
></EntityReference><EntityValidator Assembly="Unknown" /><Fields><IDProject><CurrentValue Type="System.Int32">1</CurrentValue><DbValue Type="System.Int32">1</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></IDProject><IDClient><CurrentValue Type="System.Int32">1</CurrentValue><DbValue Type="System.Int32">1</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></IDClient><Name><CurrentValue Type="System.String">HITS</CurrentValue><DbValue Type="System.String">HITS</DbValue><IsChanged Type="System.Boolean">False</IsChanged><IsNull Type="System.Boolean">False</IsNull></Name></Fields><LLBLGenProEntityName Type="System.String">ProjectEntity</LLBLGenProEntityName><CustomPropertiesOfType Type="System.Collections.Hashtable">System.Collections.Hashtable</CustomPropertiesOfType><IsDirty Type="System.Boolean">False</IsDirty><EntityState Type="SD.LLBLGen.Pro.ORMSupportClasses.EntityState">Fetched</EntityState><SavedFiel
dSets /></ProjectEntity></EntityReference><LLBLGenProEntityName Type="System.String">TimeRecordEntity</LLBLGenProEntityName><CustomPropertiesOfType Type="System.Collections.Hashtable">System.Collections.Hashtable</CustomPropertiesOfType><IsDirty Type="System.Boolean">False</IsDirty><EntityState Type="SD.LLBLGen.Pro.ORMSupportClasses.EntityState">Fetched</EntityState><SavedFieldSets /></TimeRecordEntity><ProcessedObjectReference ObjectID="420d98dd-ef90-4733-8e79-032844a862c8" /><ProcessedObjectReference ObjectID="4bb4865f-9cf7-4cab-aa52-dda25deb9393" /><ProcessedObjectReference ObjectID="9fbc122c-b3b7-425a-bd27-cf3a3852c88d" /></Entities><DoNotPerformAddIfPresent Type="System.Boolean">True</DoNotPerformAddIfPresent><AllowNew Type="System.Boolean">True</AllowNew><Count Type="System.Int32">4</Count><EntityFactoryToUse Assembly="JGG.Timesheet.LLBL, Version=1.0.1788.21094, Culture=neutral, PublicKeyToken=null" Type="JGG.Timesheet.LLBL.FactoryClasses.TimeRecordEntityFactory" /><SupportsSorting Type="System.Boolean">
False</SupportsSorting><SupportsSearching Type="System.Boolean">True</SupportsSearching><Validator Assembly="Unknown" /><SupportsChangeNotification Type="System.Boolean">True</SupportsChangeNotification><AllowRemove Type="System.Boolean">False</AllowRemove><IsReadOnly Type="System.Boolean">False</IsReadOnly><AllowEdit Type="System.Boolean">True</AllowEdit></EntityCollection>"

Yeeesh...hope that helps disappointed

Jeff...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 23-Nov-2004 21:33:15   

Well, you're not using strongly typed assemblies which are not in sync, so in theory it should work.

Short test, for now: if you call ReadXml() on the server, does that work or does that crash as well?

Frans Bouma | Lead developer LLBLGen Pro
jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 23-Nov-2004 21:49:36   

Otis wrote:

Short test, for now: if you call ReadXml() on the server, does that work or does that crash as well?

Nope, fails on the server with the same exception... can you tell whether the XML looks correct?

Jeff...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 23-Nov-2004 22:09:04   

The cyclic reference tags looked kinda odd.

To make me able to test it properly tomorrow (wednesday), could you describe the hierarchy of the entities (i.e. the relation types between them), then I'll try to mimic it here with a lookalike graph.

Frans Bouma | Lead developer LLBLGen Pro
jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 23-Nov-2004 22:27:21   

Otis wrote:

The cyclic reference tags looked kinda odd.

To make me able to test it properly tomorrow (wednesday), could you describe the hierarchy of the entities (i.e. the relation types between them), then I'll try to mimic it here with a lookalike graph.

Here's the DDL for the tables:


CREATE TABLE [dbo].[Client] (
    [IDClient] [int] IDENTITY (1, 1) NOT NULL ,
    [Name] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Project] (
    [IDProject] [int] IDENTITY (1, 1) NOT NULL ,
    [IDClient] [int] NULL ,
    [Name] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TimeRecord] (
    [IDTimeRecord] [int] IDENTITY (1, 1) NOT NULL ,
    [IDProject] [int] NULL ,
    [beginDT] [datetime] NULL ,
    [endDT] [datetime] NULL ,
    [Comment] [varchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Client] WITH NOCHECK ADD 
    CONSTRAINT [PK_Client] PRIMARY KEY  CLUSTERED 
    (
        [IDClient]
    )  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Project] WITH NOCHECK ADD 
    CONSTRAINT [PK_Project] PRIMARY KEY  CLUSTERED 
    (
        [IDProject]
    )  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[TimeRecord] WITH NOCHECK ADD 
    CONSTRAINT [PK_TimeRecord] PRIMARY KEY  CLUSTERED 
    (
        [IDTimeRecord]
    )  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Project] ADD 
    CONSTRAINT [FK_Project_Client] FOREIGN KEY 
    (
        [IDClient]
    ) REFERENCES [dbo].[Client] (
        [IDClient]
    )
GO

ALTER TABLE [dbo].[TimeRecord] ADD 
    CONSTRAINT [FK_TimeRecord_Project] FOREIGN KEY 
    (
        [IDProject]
    ) REFERENCES [dbo].[Project] (
        [IDProject]
    )
GO


Basically:

Client 1:n Project 1:n TimeRecord

By the way, have you ever thought about moving to California? We've got great weather, beautiful landscape, both mountains and beach < 2 hours away. Best of all, you and your great support will be in the same time zone as me instead of, you know like 9 hours apart. stuck_out_tongue_winking_eye

Jeff...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 24-Nov-2004 10:26:45   

I've written this test:


[Test]
public void ReadXmlWriteXmlWithPrefetchPathsTest()
{
    DataAccessAdapter adapter = new DataAccessAdapter();

    try
    {
        EntityCollection customers = new EntityCollection(new CustomerEntityFactory());
        IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.CustomerEntity);
        prefetchPath.Add(CustomerEntity.PrefetchPathOrders).SubPath.Add(OrderEntity.PrefetchPathOrderDetails);
        RelationPredicateBucket filter = new RelationPredicateBucket();
        filter.PredicateExpression.Add(PredicateFactory.CompareValue(CustomerFieldIndex.Country, ComparisonOperator.Equal, "France"));
        adapter.FetchEntityCollection(customers, filter, prefetchPath);

        Assert.AreEqual(11, customers.Count);

        string customersXml = string.Empty;
        customers.WriteXml(out customersXml);

        EntityCollection customersFromXml = new EntityCollection(new CustomerEntityFactory());
        customersFromXml.ReadXml(customersXml);

        Assert.AreEqual(11, customersFromXml.Count);

        // the other way around.
        EntityCollection orderDetails = new EntityCollection(new OrderDetailsEntityFactory());
        prefetchPath = new PrefetchPath2((int)EntityType.OrderDetailsEntity);
        prefetchPath.Add(OrderDetailsEntity.PrefetchPathOrders).SubPath.Add(OrderEntity.PrefetchPathCustomers);
        filter = new RelationPredicateBucket();
        filter.PredicateExpression.Add(PredicateFactory.CompareValue(OrderDetailsFieldIndex.ProductId, ComparisonOperator.Equal, 3));
        adapter.FetchEntityCollection(orderDetails, filter, prefetchPath);

        Assert.AreEqual(11, orderDetails.Count);

        string orderDetailsXml = string.Empty;
        orderDetails.WriteXml(out orderDetailsXml);

        EntityCollection orderDetailsFromXml = new EntityCollection(new OrderDetailsEntityFactory());
        orderDetailsFromXml.ReadXml(orderDetailsXml);

        Assert.AreEqual(11, orderDetailsFromXml.Count);

    }
    finally
    {
        adapter.Dispose();
    }
}

The graph can be fetched and used from 2 sides: customer -> order -> order details or order details -> order -> customer

The first is the first part of the test and this works as expected. The second part of the test, does the same as you're doing, and tests the second graph type order details -> order -> customer which fails with the same order.

I'll try to fix this now. simple_smile

(edit) the weird part is: when I specify product '9' instead of '3', which results in 5 orders instead of 11, it works ok!... very strange.

(edit)It's something with the cyclic reference solver routine, hmm...

(edit)ok found it (the cause). WHen a prefetch path is used using a graph with m:1 relations, it can be that there are objects related to the same object. In my example, several order detail objects can be related to the same customer, so these orders end up in the same orders collection and the WriteXml routine then processes them already, but there is a bug somewhere in teh ReadXml() routine which apparently doesn't log these instances in the hashtable so these aren't found back later on, resulting in null and the error.

(edit)Ok fixed it. It went wrong when an entity in a collection was already processed so a cyclic reference node was added to the xml. This caused the loop to break, instead of continue, so the following nodes were never processed.

I'll upload a hotfix to the website a.s.a.p. Build 1.0.2004.1.11242004

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 24-Nov-2004 12:10:37   

Fixed in RT 1.0.2004.1.11242004. Hotfix now available.

The hotfix already contains the MySql DQE, which driver package will be uploaded as BETA later today.

Frans Bouma | Lead developer LLBLGen Pro
jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 24-Nov-2004 19:37:16   

Otis wrote:

Fixed in RT 1.0.2004.1.11242004. Hotfix now available.

The hotfix already contains the MySql DQE, which driver package will be uploaded as BETA later today.

Thanks, Frans. I'll give it a try and let you know. BTW, do you guys celebrate Thanksgiving over there? If so, have a happy one!

Jeff...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 24-Nov-2004 21:01:13   

jeffreygg wrote:

Otis wrote:

Fixed in RT 1.0.2004.1.11242004. Hotfix now available.

The hotfix already contains the MySql DQE, which driver package will be uploaded as BETA later today.

Thanks, Frans. I'll give it a try and let you know. BTW, do you guys celebrate Thanksgiving over there? If so, have a happy one! Jeff...

simple_smile No we don't celebrate thanksgiving, I believe that's a USA only holiday simple_smile

But to you a happy thanksgiving too simple_smile

Frans Bouma | Lead developer LLBLGen Pro