[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Framework 1.1--Child referencing in expression columns does not work for self-joined tables

Tony Chow

1/22/2003 11:27:00 AM

The 1.1 Framework/SDK apparently resolves a lot of the problems with
expression columns that version 1.0 had. However, I stumbled upon a bug
that occurs with expression columns in self-joined tables--that is, tables
with a foreign key pointing to another field in the same table. In such
cases, child referencing in expression columns does not seem to work.

Here's a very simple example. Let's say you've got a simple dataset with a
single table in it, TestTable. The primary key is a field called
TestTable_ID, Each record in TestTable can have multiple subrecords, each of
which relates to its parent record through a Master_TestTable_ID field (a
null value in the first level records). The table has an expression column
called Children_Count, which returns a count of a given record's child
records with the expression "Count(Child.TestTable_ID)". The problem is
that this expression always returns zero, no matter how many children a
TestTable record has.

Here's the XSD file and the demonstration code:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="testds" targetNamespace="http://tempuri.org/testds...
elementFormDefault="qualified" attributeFormDefault="qualified"
xmlns="http://tempuri.org/testds...
xmlns:mstns="http://tempuri.org/testds...
xmlns:xs="http://www.w3.org/2001/XMLSc...
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="testds" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="TestTable">
<xs:complexType>
<xs:sequence>
<xs:element name="TestTable_ID" type="xs:int"
minOccurs="0" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="1"
msdata:AutoIncrementStep="1" />
<xs:element name="Master_TestTable_ID"
type="xs:int" minOccurs="0" nillable="true" />
<xs:element name="Children_Count" type="xs:int"
minOccurs="0"
msdata:Expression="Count(Child(TestTableTestTable).TestTable_ID)" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="testdsKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:TestTable" />
<xs:field xpath="mstns:TestTable_ID" />
</xs:key>
<xs:keyref name="TestTableTestTable" refer="testdsKey1">
<xs:selector xpath=".//mstns:TestTable" />
<xs:field xpath="mstns:Master_TestTable_ID" />
</xs:keyref>
</xs:element>
</xs:schema>

Demonstration code:

testds ds;
testds.TestTableRow row1, row2;
ds = new testds();
row1 = ds.TestTable.NewTestTableRow();
ds.TestTable.AddTestTableRow(row1);
row2 = ds.TestTable.NewTestTableRow();
row2.Master_TestTable_ID = row.TestTable_ID;
ds.TestTable.AddTestTableRow(row2);

MessageBox.Show(row1.Children_Count.ToString());

The message box shows 0.


2 Answers

Tony Chow

1/23/2003 2:13:00 AM

0

No answer whatsoever? This is a real problem and I hope it does get fixed
by release.


msnews.microsoft.com

1/23/2003 9:58:00 PM

0

Isn't it a bit close to release for that sort of fix?

--
John Saunders
Internet Engineer
john.saunders@surfcontrol.com


"Tony Chow" <tchow@bluetentacle.com> wrote in message
news:OFeY4wnwCHA.1288@TK2MSFTNGP11...
> No answer whatsoever? This is a real problem and I hope it does get fixed
> by release.
>
>