This is a multi-part message in MIME format.
------=_NextPart_000_0014_01C885D7.7465A360
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I have a test DBML file:-
<?xml version=3D"1.0" encoding=3D"utf-8"?>
<Database Name=3D"myDB" EntityNamespace=3D"MyEntNS" =
ContextNamespace=3D"MyConNs" Class=3D"DBdc" =
xmlns=3D"http://schemas.microsoft.com/linqtosql/dbml/2007">
<Table Name=3D"dbo.PARENTTABLE" Member=3D"PARENTTABLE">
<Type Name=3D"PARENTTABLE">
<Column Name=3D"keycol1" Member=3D"keycol1" =
Type=3D"System.Decimal" DbType=3D"Decimal(10,0) NOT NULL" =
IsPrimaryKey=3D"true" CanBeNull=3D"false" />
<Column Name=3D"keycol2" Member=3D"keycol2" =
Type=3D"System.Decimal" DbType=3D"Decimal(10,0) NOT NULL" =
IsPrimaryKey=3D"true" CanBeNull=3D"false" />
<Column Name=3D"keycol3" Member=3D"keycol3" Type=3D"System.String" =
DbType=3D"VarChar(10) NOT NULL" IsPrimaryKey=3D"true" =
CanBeNull=3D"false" />
<Association Name=3D"fk_1064" Member=3D"fkCHILDTABLE" =
ThisKey=3D"keycol3,keycol1,keycol2" =
OtherKey=3D"fkeycol3,fkeycol1,fkeycol2" Type=3D"CHILDTABLE" =
DeleteRule=3D"NO ACTION" />
</Type>
</Table>
<Table Name=3D"dbo.CHILDTABLE" Member=3D"CHILDTABLE">
<Type Name=3D"CHILDTABLE">
<Column Name=3D"main_id" Member=3D"publish_id" =
Type=3D"System.String" DbType=3D"VarChar(10) NOT NULL" =
IsPrimaryKey=3D"true" CanBeNull=3D"false" />
<Column Name=3D"fkeycol1" Member=3D"fkeycol1" =
Type=3D"System.Decimal" DbType=3D"Decimal(10,0)" CanBeNull=3D"true" />
<Column Name=3D"fkeycol2" Member=3D"fkeycol2" =
Type=3D"System.Decimal" DbType=3D"Decimal(10,0)" CanBeNull=3D"true" />
<Column Name=3D"fkeycol3" Member=3D"fkeycol3" =
Type=3D"System.String" DbType=3D"VarChar(10)" CanBeNull=3D"true" />
<Association Name=3D"fk_1064" Member=3D"pkPARENTTABLE" =
ThisKey=3D"fkeycol3,fkeycol1,fkeycol2" =
OtherKey=3D"keycol3,keycol1,keycol2" Type=3D"PARENTTABLE" =
IsForeignKey=3D"true" />
</Type>
</Table>
</Database>
Note that the order of the columns on the PARENTTABLE are listed =
correctly as keycol1, keycol2, keycol3, but the promary key on the table =
is actually keycol3, keycol1, keycol2. The association elements do use =
the correct primary key sequences. However, when I generate the VB for =
this DBML, it gets it wrong.. see the text below highlighted in red.
<Association(Name:=3D"fk_1064", Storage:=3D"_pkPARENTTABLE", =
ThisKey:=3D"fkeycol3,fkeycol1,fkeycol2", IsForeignKey:=3Dtrue)> _
Public Property pkPARENTTABLE() As PARENTTABLE
Get
Return Me._pkPARENTTABLE.Entity
End Get
Set
Dim previousValue As PARENTTABLE =3D Me._pkPARENTTABLE.Entity
If ((Object.Equals(previousValue, value) =3D false) _
OrElse (Me._pkPARENTTABLE.HasLoadedOrAssignedValue =3D false)) =
Then
Me.SendPropertyChanging
If ((previousValue Is Nothing) _
=3D false) Then
Me._pkPARENTTABLE.Entity =3D Nothing
previousValue.fkCHILDTABLE.Remove(Me)
End If
Me._pkPARENTTABLE.Entity =3D value
If ((value Is Nothing) _
=3D false) Then
value.fkCHILDTABLE.Add(Me)
Me._fkeycol3 =3D value.keycol1
Me._fkeycol1 =3D value.keycol2
Me._fkeycol2 =3D value.keycol3
Else
Me._fkeycol3 =3D CType(Nothing, String)
Me._fkeycol1 =3D CType(Nothing, Nullable(Of Decimal))
Me._fkeycol2 =3D CType(Nothing, Nullable(Of Decimal))
End If
Me.SendPropertyChanged("pkPARENTTABLE")
End If
End Set
End Property
Is there something wrong with the DBML or is it a bug in SQLMetal ?=20
(this is using the RTM (1.00.21022) version of SQLMetal)
--=20
Adrian
------=_NextPart_000_0014_01C885D7.7465A360
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.3268" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DCalibri size=3D2>I have a test DBML =
file:-</FONT></DIV>
<DIV><FONT face=3DCalibri size=3D2></FONT> </DIV>
<DIV><FONT face=3DCalibri><FONT color=3D#000080 size=3D1><?xml =
version=3D"1.0"=20
encoding=3D"utf-8"?><BR><Database Name=3D"myDB" =
EntityNamespace=3D"MyEntNS"=20
ContextNamespace=3D"MyConNs" Class=3D"DBdc" xmlns=3D"</FONT><A=20
href=3D"http://schemas.microsoft.com/linqtosql/dbml/2007"><FONT =
color=3D#000080=20
size=3D1>http://schemas.microsoft.com/linqtosql/dbml/2007</FONT></A><FONT=
=20
color=3D#000080 size=3D1>"><BR> <Table =
Name=3D"dbo.PARENTTABLE"=20
Member=3D"PARENTTABLE"><BR> <Type=20
Name=3D"PARENTTABLE"><BR> <Column=20
Name=3D"keycol1" Member=3D"keycol1" Type=3D"System.Decimal" =
DbType=3D"Decimal(10,0) NOT=20
NULL" IsPrimaryKey=3D"true" CanBeNull=3D"false"=20
/><BR> <Column Name=3D"keycol2"=20
Member=3D"keycol2" Type=3D"System.Decimal" DbType=3D"Decimal(10,0) NOT =
NULL"=20
IsPrimaryKey=3D"true" CanBeNull=3D"false" =
/><BR> =20
<Column Name=3D"keycol3" Member=3D"keycol3" Type=3D"System.String"=20
DbType=3D"VarChar(10) NOT NULL" IsPrimaryKey=3D"true" =
CanBeNull=3D"false"=20
/><BR> <Association Name=3D"fk_1064" =
Member=3D"fkCHILDTABLE" ThisKey=3D"keycol3,keycol1,keycol2"=20
OtherKey=3D"fkeycol3,fkeycol1,fkeycol2" Type=3D"CHILDTABLE" =
DeleteRule=3D"NO ACTION"=20
/><BR> </Type><BR> =
</Table><BR> =20
<Table Name=3D"dbo.CHILDTABLE" =
Member=3D"CHILDTABLE"><BR> =20
<Type Name=3D"CHILDTABLE"><BR> =
<Column=20
Name=3D"main_id" Member=3D"publish_id" Type=3D"System.String" =
DbType=3D"VarChar(10) NOT=20
NULL" IsPrimaryKey=3D"true" CanBeNull=3D"false"=20
/><BR> <Column Name=3D"fkeycol1"=20
Member=3D"fkeycol1" Type=3D"System.Decimal" DbType=3D"Decimal(10,0)" =
CanBeNull=3D"true"=20
/><BR> <Column Name=3D"fkeycol2"=20
Member=3D"fkeycol2" Type=3D"System.Decimal" DbType=3D"Decimal(10,0)" =
CanBeNull=3D"true"=20
/><BR> <Column Name=3D"fkeycol3"=20
Member=3D"fkeycol3" Type=3D"System.String" DbType=3D"VarChar(10)" =
CanBeNull=3D"true"=20
/><BR> <Association Name=3D"fk_1064" =
Member=3D"pkPARENTTABLE" ThisKey=3D"fkeycol3,fkeycol1,fkeycol2"=20
OtherKey=3D"keycol3,keycol1,keycol2" Type=3D"PARENTTABLE" =
IsForeignKey=3D"true"=20
/><BR> </Type><BR> =20
</Table><BR></Database></FONT></FONT></DIV>
<DIV><FONT face=3DCalibri size=3D2></FONT> </DIV>
<DIV><FONT face=3DCalibri size=3D2>Note that the order of the columns on =
the=20
PARENTTABLE are listed correctly as keycol1, keycol2, keycol3, but the =
promary=20
key on the table is actually keycol3, keycol1, keycol2. The =
association=20
elements do use the correct primary key sequences. However, =
when I=20
generate the VB for this DBML, it gets it wrong.. see the text =
below=20
highlighted in red.</FONT></DIV>
<DIV><FONT face=3DCalibri size=3D2></FONT> </DIV>
<DIV><FONT face=3DCalibri size=3D2><FONT color=3D#000080><FONT=20
size=3D1> <Association(Name:=3D"fk_1064", =
Storage:=3D"_pkPARENTTABLE",=20
ThisKey:=3D"fkeycol3,fkeycol1,fkeycol2", IsForeignKey:=3Dtrue)> =
_<BR> Public Property pkPARENTTABLE() As=20
PARENTTABLE<BR> Get<BR> Return=20
Me._pkPARENTTABLE.Entity<BR> End=20
Get<BR> Set<BR> Dim =
previousValue As=20
PARENTTABLE =3D Me._pkPARENTTABLE.Entity<BR> If=20
((Object.Equals(previousValue, value) =3D false) =20
_<BR> OrElse=20
(Me._pkPARENTTABLE.HasLoadedOrAssignedValue =3D false))=20
Then<BR> Me.SendPropertyChanging<BR> &n=
bsp; If=20
((previousValue Is Nothing) =20
_<BR> =3D false)=20
Then<BR> Me._pkPARENTTABLE.Entity =3D =
Nothing<BR> previousValue.fkCHILDTABLE=
.Remove(Me)<BR> End=20
If<BR> Me._pkPARENTTABLE.Entity =3D=20
value<BR> If ((value Is Nothing) =20
_<BR> =3D false)=20
Then<BR> value.fkCHILDTABLE.Add(Me)<BR=
></FONT><FONT=20
size=3D1><FONT=20
color=3D#ff0000><STRONG> Me._fkeycol3 =
=3D=20
value.keycol1<BR> Me._fkeycol1 =3D=20
value.keycol2<BR> Me._fkeycol2 =3D=20
value.keycol3</STRONG></FONT><BR> Else<BR>&n=
bsp; Me._fkeycol3=20
=3D CType(Nothing, =
String)<BR> Me._fkeycol1 =3D=20
CType(Nothing, Nullable(Of=20
Decimal))<BR> Me._fkeycol2 =3D =
CType(Nothing,=20
Nullable(Of Decimal))<BR> End=20
If<BR> Me.SendPropertyChanged("pkPARENTTABLE=
")<BR> End=20
If<BR> End Set<BR> End=20
Property</FONT><BR></FONT><BR>Is there something wrong with the DBML or =
is it a=20
bug in SQLMetal ? </FONT></DIV>
<DIV><FONT face=3DCalibri size=3D2></FONT> </DIV>
<DIV><FONT face=3DCalibri size=3D2>(this is using the RTM (1.00.21022) =
version of=20
SQLMetal)</FONT></DIV>
<DIV><FONT face=3DCalibri size=3D2>-- <BR>Adrian</DIV>
<DIV> </DIV>
<DIV></FONT> </DIV></BODY></HTML>
------=_NextPart_000_0014_01C885D7.7465A360--