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>&nbsp;</DIV>
<DIV><FONT face=3DCalibri><FONT color=3D#000080 size=3D1>&lt;?xml =
version=3D"1.0"=20
encoding=3D"utf-8"?&gt;<BR>&lt;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>"&gt;<BR>&nbsp; &lt;Table =
Name=3D"dbo.PARENTTABLE"=20
Member=3D"PARENTTABLE"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;Type=20
Name=3D"PARENTTABLE"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;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
/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;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" =
/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;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
/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;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
/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/Type&gt;<BR>&nbsp; =
&lt;/Table&gt;<BR>&nbsp;=20
&lt;Table Name=3D"dbo.CHILDTABLE" =
Member=3D"CHILDTABLE"&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;Type Name=3D"CHILDTABLE"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&lt;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
/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Column Name=3D"fkeycol1"=20
Member=3D"fkeycol1" Type=3D"System.Decimal" DbType=3D"Decimal(10,0)" =
CanBeNull=3D"true"=20
/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Column Name=3D"fkeycol2"=20
Member=3D"fkeycol2" Type=3D"System.Decimal" DbType=3D"Decimal(10,0)" =
CanBeNull=3D"true"=20
/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Column Name=3D"fkeycol3"=20
Member=3D"fkeycol3" Type=3D"System.String" DbType=3D"VarChar(10)" =
CanBeNull=3D"true"=20
/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;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
/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/Type&gt;<BR>&nbsp;=20
&lt;/Table&gt;<BR>&lt;/Database&gt;</FONT></FONT></DIV>
<DIV><FONT face=3DCalibri size=3D2></FONT>&nbsp;</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.&nbsp; The =
association=20
elements do use the correct primary key sequences.&nbsp;&nbsp; However, =
when I=20
generate the VB for this DBML, it gets it wrong..&nbsp; see the text =
below=20
highlighted in red.</FONT></DIV>
<DIV><FONT face=3DCalibri size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DCalibri size=3D2><FONT color=3D#000080><FONT=20
size=3D1>&nbsp;&nbsp;&lt;Association(Name:=3D"fk_1064", =
Storage:=3D"_pkPARENTTABLE",=20
ThisKey:=3D"fkeycol3,fkeycol1,fkeycol2", IsForeignKey:=3Dtrue)&gt;&nbsp; =

_<BR>&nbsp;&nbsp;Public Property pkPARENTTABLE() As=20
PARENTTABLE<BR>&nbsp;&nbsp;&nbsp;Get<BR>&nbsp;&nbsp;&nbsp;&nbsp;Return=20
Me._pkPARENTTABLE.Entity<BR>&nbsp;&nbsp;&nbsp;End=20
Get<BR>&nbsp;&nbsp;&nbsp;Set<BR>&nbsp;&nbsp;&nbsp;&nbsp;Dim =
previousValue As=20
PARENTTABLE =3D Me._pkPARENTTABLE.Entity<BR>&nbsp;&nbsp;&nbsp;&nbsp;If=20
((Object.Equals(previousValue, value) =3D false)&nbsp;=20
_<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OrElse=20
(Me._pkPARENTTABLE.HasLoadedOrAssignedValue =3D false))=20
Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.SendPropertyChanging<BR>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;If=20
((previousValue Is Nothing)&nbsp;=20
_<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D false)=20
Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me._pkPARENTTABLE.Entity =3D =

Nothing<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;previousValue.fkCHILDTABLE=
.Remove(Me)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End=20
If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me._pkPARENTTABLE.Entity =3D=20
value<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If ((value Is Nothing)&nbsp;=20
_<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D false)=20
Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value.fkCHILDTABLE.Add(Me)<BR=
></FONT><FONT=20
size=3D1><FONT=20
color=3D#ff0000><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me._fkeycol3 =
=3D=20
value.keycol1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me._fkeycol1 =3D=20
value.keycol2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me._fkeycol2 =3D=20
value.keycol3</STRONG></FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<BR>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me._fkeycol3=20
=3D CType(Nothing, =
String)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me._fkeycol1 =3D=20
CType(Nothing, Nullable(Of=20
Decimal))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me._fkeycol2 =3D =
CType(Nothing,=20
Nullable(Of Decimal))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End=20
If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.SendPropertyChanged("pkPARENTTABLE=
")<BR>&nbsp;&nbsp;&nbsp;&nbsp;End=20
If<BR>&nbsp;&nbsp;&nbsp;End Set<BR>&nbsp;&nbsp;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>&nbsp;</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>&nbsp;</DIV>
<DIV></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0014_01C885D7.7465A360--

RE: SQLMetal - Problem generating VB from DBML by stcheng

stcheng
Mon Mar 17 01:26:01 CDT 2008

Hi Adrian,

As for the DBML file you provided, how did you generate it?

For general validation, you can use the DBML schemas to validate the DBML
to see whether there is any XML schema specific errors. Here is the MSDN
reference about this:

#How to: Validate DBML and External Mapping Files (LINQ to SQL)
http://msdn2.microsoft.com/en-us/library/bb882675.aspx

if there doesn't exist such error. I think there may have some certain
database related things cause potential problems.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>Reply-To: "Adrian" <apparker@nospam.nospam>
>From: "Adrian" <apparker@nospam.nospam>
>Subject: SQLM

>I have a test DBML file:-
><?xml version="1.0" encoding="utf-8"?>
><Database Name="myDB" EntityNamespace="MyEntNS" ContextNamespace="MyConNs"
Class="DBdc" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
> <Table Name="dbo.PARENTTABLE" Member="PARENTTABLE">
> <Type Name="PARENTTABLE">
> <Column Name="keycol1" Member="keycol1" Type="System.Decimal"
DbType="Decimal(10,0) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
> <Column Name="keycol2" Member="keycol2" Type="System.Decimal"
DbType="Decimal(10,0) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
> <Column Name="keycol3" Member="keycol3" Type="System.String"
DbType="VarChar(10) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
> <Association Name="fk_1064" Member="fkCHILDTABLE"
ThisKey="keycol3,keycol1,keycol2" OtherKey="fkeycol3,fkeycol1,fkeycol2"
Type="CHILDTABLE" DeleteRule="NO ACTION" />
> </Type>
> </Table>
> <Table Name="dbo.CHILDTABLE" Member="CHILDTABLE">
> <Type Name="CHILDTABLE">
> <Column Name="main_id" Member="publish_id" Type="System.String"
DbType="VarChar(10) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
> <Column Name="fkeycol1" Member="fkeycol1" Type="System.Decimal"
DbType="Decimal(10,0)" CanBeNull="true" />
> <Column Name="fkeycol2" Member="fkeycol2" Type="System.Decimal"
DbType="Decimal(10,0)" CanBeNull="true" />
> <Column Name="fkeycol3" Member="fkeycol3" Type="System.String"
DbType="VarChar(10)" CanBeNull="true" />
> <Association Name="fk_1064" Member="pkPARENTTABLE"
ThisKey="fkeycol3,fkeycol1,fkeycol2" OtherKey="keycol3,keycol1,keycol2"
Type="PARENTTABLE" IsForeignKey="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:="fk_1064", Storage:="_pkPARENTTABLE",
ThisKey:="fkeycol3,fkeycol1,fkeycol2", IsForeignKey:=true)> _
> Public Property pkPARENTTABLE() As PARENTTABLE
> Get
> Return Me._pkPARENTTABLE.Entity
> End Get
> Set
> Dim previousValue As PARENTTABLE = Me._pkPARENTTABLE.Entity
> If ((Object.Equals(previousValue, value) = false) _
> OrElse (Me._pkPARENTTABLE.HasLoadedOrAssignedValue = false)) Then
> Me.SendPropertyChanging
> If ((previousValue Is Nothing) _
> = false) Then
> Me._pkPARENTTABLE.Entity = Nothing
> previousValue.fkCHILDTABLE.Remove(Me)
> End If
> Me._pkPARENTTABLE.Entity = value
> If ((value Is Nothing) _
> = false) Then
> value.fkCHILDTABLE.Add(Me)
> Me._fkeycol3 = value.keycol1
> Me._fkeycol1 = value.keycol2
> Me._fkeycol2 = value.keycol3
> Else
> Me._fkeycol3 = CType(Nothing, String)
> Me._fkeycol1 = CType(Nothing, Nullable(Of Decimal))
> Me._fkeycol2 = 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 ?
>(this is using the RTM (1.00.21022) version of SQLMetal)
>--
>Adrian
>


Re: SQLMetal - Problem generating VB from DBML by Adrian

Adrian
Mon Mar 17 05:50:34 CDT 2008

Steven,

The dbml file is one we 'adjust' from the normal one generated by SQLMetal..
we have to 'fix' some of the Member entries as they're badly named by
sqlmetal.

Followd your link and tried to validate, but when I go to the properties
window in VS, it doesn't give me a 'Schema' property to select.. it just
gives..

Access: Public
Base Class: System.Data.Linq.DataContext
+Connection
Context Namespace: MyConNS
Entity Namespace: MyEntNs
Inheritance Modifier: (None)
Name: DBdc
Serialization Mode: None


Anyway, thinking about it, it does generate the VB, it just gets some
columns switched around. As I said, it seems like it's not using the order
of the ThisKey and OtherKey when creating the code, but is taking the order
of the columns in the <column> elements.




""Steven Cheng"" <stcheng@online.microsoft.com> wrote in message
news:SBISRf$hIHA.4672@TK2MSFTNGHUB02.phx.gbl...
| Hi Adrian,
|
| As for the DBML file you provided, how did you generate it?
|
| For general validation, you can use the DBML schemas to validate the DBML
| to see whether there is any XML schema specific errors. Here is the MSDN
| reference about this:
|
| #How to: Validate DBML and External Mapping Files (LINQ to SQL)
| http://msdn2.microsoft.com/en-us/library/bb882675.aspx
|
| if there doesn't exist such error. I think there may have some certain
| database related things cause potential problems.
|
| Sincerely,
|
| Steven Cheng
|
| Microsoft MSDN Online Support Lead
|
|
| Delighting our customers is our #1 priority. We welcome your comments and
| suggestions about how we can improve the support we provide to you. Please
| feel free to let my manager know what you think of the level of service
| provided. You can send feedback directly to my manager at:
| msdnmg@microsoft.com.
|
| ==================================================
| This posting is provided "AS IS" with no warranties, and confers no
rights.
|
| --------------------
| >Reply-To: "Adrian" <apparker@nospam.nospam>
| >From: "Adrian" <apparker@nospam.nospam>
| >Subject: SQLM
|
| >I have a test DBML file:-
| ><?xml version="1.0" encoding="utf-8"?>
| ><Database Name="myDB" EntityNamespace="MyEntNS"
ContextNamespace="MyConNs"
| Class="DBdc" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
| > <Table Name="dbo.PARENTTABLE" Member="PARENTTABLE">
| > <Type Name="PARENTTABLE">
| > <Column Name="keycol1" Member="keycol1" Type="System.Decimal"
| DbType="Decimal(10,0) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
| > <Column Name="keycol2" Member="keycol2" Type="System.Decimal"
| DbType="Decimal(10,0) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
| > <Column Name="keycol3" Member="keycol3" Type="System.String"
| DbType="VarChar(10) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
| > <Association Name="fk_1064" Member="fkCHILDTABLE"
| ThisKey="keycol3,keycol1,keycol2" OtherKey="fkeycol3,fkeycol1,fkeycol2"
| Type="CHILDTABLE" DeleteRule="NO ACTION" />
| > </Type>
| > </Table>
| > <Table Name="dbo.CHILDTABLE" Member="CHILDTABLE">
| > <Type Name="CHILDTABLE">
| > <Column Name="main_id" Member="publish_id" Type="System.String"
| DbType="VarChar(10) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
| > <Column Name="fkeycol1" Member="fkeycol1" Type="System.Decimal"
| DbType="Decimal(10,0)" CanBeNull="true" />
| > <Column Name="fkeycol2" Member="fkeycol2" Type="System.Decimal"
| DbType="Decimal(10,0)" CanBeNull="true" />
| > <Column Name="fkeycol3" Member="fkeycol3" Type="System.String"
| DbType="VarChar(10)" CanBeNull="true" />
| > <Association Name="fk_1064" Member="pkPARENTTABLE"
| ThisKey="fkeycol3,fkeycol1,fkeycol2" OtherKey="keycol3,keycol1,keycol2"
| Type="PARENTTABLE" IsForeignKey="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:="fk_1064", Storage:="_pkPARENTTABLE",
| ThisKey:="fkeycol3,fkeycol1,fkeycol2", IsForeignKey:=true)> _
| > Public Property pkPARENTTABLE() As PARENTTABLE
| > Get
| > Return Me._pkPARENTTABLE.Entity
| > End Get
| > Set
| > Dim previousValue As PARENTTABLE = Me._pkPARENTTABLE.Entity
| > If ((Object.Equals(previousValue, value) = false) _
| > OrElse (Me._pkPARENTTABLE.HasLoadedOrAssignedValue = false)) Then
| > Me.SendPropertyChanging
| > If ((previousValue Is Nothing) _
| > = false) Then
| > Me._pkPARENTTABLE.Entity = Nothing
| > previousValue.fkCHILDTABLE.Remove(Me)
| > End If
| > Me._pkPARENTTABLE.Entity = value
| > If ((value Is Nothing) _
| > = false) Then
| > value.fkCHILDTABLE.Add(Me)
| > Me._fkeycol3 = value.keycol1
| > Me._fkeycol1 = value.keycol2
| > Me._fkeycol2 = value.keycol3
| > Else
| > Me._fkeycol3 = CType(Nothing, String)
| > Me._fkeycol1 = CType(Nothing, Nullable(Of Decimal))
| > Me._fkeycol2 = 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 ?
| >(this is using the RTM (1.00.21022) version of SQLMetal)
| >--
| >Adrian
| >
|



Re: SQLMetal - Problem generating VB from DBML by stcheng

stcheng
Mon Mar 24 04:34:34 CDT 2008

Hi Adrian,

For the DBML document you mentioned, I've also tested it. Yes, if we keep
the three primary columns and their order always as 1, 2, 3 in all places,
it will generate code as expected. However, if we change the order as
below(in your customized DBML):

ThisKey="keycol3,keycol1,keycol2" OtherKey="fkeycol3,fkeycol1,fkeycol2"

the code it generate does seem different between the columns order in
DBML. I'll do some further research to see whether there is anything which
can control this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
>Reply-To: "Adrian" <apparker@nospam.nospam>
>From: "Adrian" <apparker@nospam.nospam>
>References: <uPcn4ddhIHA.748@TK2MSFTNGP04.phx.gbl>
<SBISRf$hIHA.4672@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: SQLMetal - Problem generating VB from DBML
>Date: Mon, 17 Mar 2008 10:50:34 -0000
>Steven,
>
>The dbml file is one we 'adjust' from the normal one generated by
SQLMetal..
>we have to 'fix' some of the Member entries as they're badly named by
>sqlmetal.
>
>Followd your link and tried to validate, but when I go to the properties
>window in VS, it doesn't give me a 'Schema' property to select.. it just
>gives..
>
>Access: Public
>Base Class: System.Data.Linq.DataContext
>+Connection
>Context Namespace: MyConNS
>Entity Namespace: MyEntNs
>Inheritance Modifier: (None)
>Name: DBdc
>Serialization Mode: None
>
>
>Anyway, thinking about it, it does generate the VB, it just gets some
>columns switched around. As I said, it seems like it's not using the
order
>of the ThisKey and OtherKey when creating the code, but is taking the
order
>of the columns in the <column> elements.
>
>
>
>
>""Steven Cheng"" <stcheng@online.microsoft.com> wrote in message
>news:SBISRf$hIHA.4672@TK2MSFTNGHUB02.phx.gbl...
>| Hi Adrian,
>|
>| As for the DBML file you provided, how did you generate it?
>|
>| For general validation, you can use the DBML schemas to validate the DBML
>| to see whether there is any XML schema specific errors. Here is the MSDN
>| reference about this:
>|
>| #How to: Validate DBML and External Mapping Files (LINQ to SQL)
>| http://msdn2.microsoft.com/en-us/library/bb882675.aspx
>|
>| if there doesn't exist such error. I think there may have some certain
>| database related things cause potential problems.
>|
>| Sincerely,
>|
>| Steven Cheng
>|
>| Microsoft MSDN Online Support Lead
>|
>|
>| Delighting our customers is our #1 priority. We welcome your comments and
>| suggestions about how we can improve the support we provide to you.
Please
>| feel free to let my manager know what you think of the level of service
>| provided. You can send feedback directly to my manager at:
>| msdnmg@microsoft.com.
>|
>| ==================================================
>| This posting is provided "AS IS" with no warranties, and confers no
>rights.
>|
>| --------------------
>| >Reply-To: "Adrian" <apparker@nospam.nospam>
>| >From: "Adrian" <apparker@nospam.nospam>
>| >Subject: SQLM
>|
>| >I have a test DBML file:-
>| ><?xml version="1.0" encoding="utf-8"?>
>| ><Database Name="myDB" EntityNamespace="MyEntNS"
>ContextNamespace="MyConNs"
>| Class="DBdc" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
>| > <Table Name="dbo.PARENTTABLE" Member="PARENTTABLE">
>| > <Type Name="PARENTTABLE">
>| > <Column Name="keycol1" Member="keycol1" Type="System.Decimal"
>| DbType="Decimal(10,0) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
>| > <Column Name="keycol2" Member="keycol2" Type="System.Decimal"
>| DbType="Decimal(10,0) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
>| > <Column Name="keycol3" Member="keycol3" Type="System.String"
>| DbType="VarChar(10) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
>| > <Association Name="fk_1064" Member="fkCHILDTABLE"
>| ThisKey="keycol3,keycol1,keycol2" OtherKey="fkeycol3,fkeycol1,fkeycol2"
>| Type="CHILDTABLE" DeleteRule="NO ACTION" />
>| > </Type>
>| > </Table>
>| > <Table Name="dbo.CHILDTABLE" Member="CHILDTABLE">
>| > <Type Name="CHILDTABLE">
>| > <Column Name="main_id" Member="publish_id" Type="System.String"
>| DbType="VarChar(10) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
>| > <Column Name="fkeycol1" Member="fkeycol1" Type="System.Decimal"
>| DbType="Decimal(10,0)" CanBeNull="true" />
>| > <Column Name="fkeycol2" Member="fkeycol2" Type="System.Decimal"
>| DbType="Decimal(10,0)" CanBeNull="true" />
>| > <Column Name="fkeycol3" Member="fkeycol3" Type="System.String"
>| DbType="VarChar(10)" CanBeNull="true" />
>| > <Association Name="fk_1064" Member="pkPARENTTABLE"
>| ThisKey="fkeycol3,fkeycol1,fkeycol2" OtherKey="keycol3,keycol1,keycol2"
>| Type="PARENTTABLE" IsForeignKey="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:="fk_1064", Storage:="_pkPARENTTABLE",
>| ThisKey:="fkeycol3,fkeycol1,fkeycol2", IsForeignKey:=true)> _
>| > Public Property pkPARENTTABLE() As PARENTTABLE
>| > Get
>| > Return Me._pkPARENTTABLE.Entity
>| > End Get
>| > Set
>| > Dim previousValue As PARENTTABLE = Me._pkPARENTTABLE.Entity
>| > If ((Object.Equals(previousValue, value) = false) _
>| > OrElse (Me._pkPARENTTABLE.HasLoadedOrAssignedValue = false)) Then
>| > Me.SendPropertyChanging
>| > If ((previousValue Is Nothing) _
>| > = false) Then
>| > Me._pkPARENTTABLE.Entity = Nothing
>| > previousValue.fkCHILDTABLE.Remove(Me)
>| > End If
>| > Me._pkPARENTTABLE.Entity = value
>| > If ((value Is Nothing) _
>| > = false) Then
>| > value.fkCHILDTABLE.Add(Me)
>| > Me._fkeycol3 = value.keycol1
>| > Me._fkeycol1 = value.keycol2
>| > Me._fkeycol2 = value.keycol3
>| > Else
>| > Me._fkeycol3 = CType(Nothing, String)
>| > Me._fkeycol1 = CType(Nothing, Nullable(Of Decimal))
>| > Me._fkeycol2 = 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 ?
>| >(this is using the RTM (1.00.21022) version of SQLMetal)
>| >--
>| >Adrian
>| >
>|
>
>
>


Re: SQLMetal - Problem generating VB from DBML by stcheng

stcheng
Wed Mar 26 01:09:47 CDT 2008

Hi Adrian,

I've performed some further research on this issue and consult some other
experts on this. Some engineers from dev team told me that this is an by
designed behavior of the LINQ DBML generation. currently, it will require
you to keep the column orders(in your "ThisKey" and "OtherKey" ) the same
as the column sequence in the table schema. Changing the order will make
the generated code become mismatch on the column/fields's assignment.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
>From: stcheng@online.microsoft.com ("Steven Cheng")
>Organization: Microsoft
>Date: Mon, 24 Mar 2008 09:34:34 GMT
>Subject: Re: SQLMetal - Problem generating VB from DBML

>
>Hi Adrian,
>
>For the DBML document you mentioned, I've also tested it. Yes, if we keep
>the three primary columns and their order always as 1, 2, 3 in all
places,
>it will generate code as expected. However, if we change the order as
>below(in your customized DBML):
>
>ThisKey="keycol3,keycol1,keycol2" OtherKey="fkeycol3,fkeycol1,fkeycol2"
>
>the code it generate does seem different between the columns order in
>DBML. I'll do some further research to see whether there is anything which
>can control this.
>
>Sincerely,
>
>Steven Cheng
>
>Microsoft MSDN Online Support Lead
>
>
>Delighting our customers is our #1 priority. We welcome your comments and
>suggestions about how we can improve the support we provide to you. Please
>feel free to let my manager know what you think of the level of service
>provided. You can send feedback directly to my manager at:
>msdnmg@microsoft.com.
>
>This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>--------------------
>>Reply-To: "Adrian" <apparker@nospam.nospam>
>>From: "Adrian" <apparker@nospam.nospam>
>>References: <uPcn4ddhIHA.748@TK2MSFTNGP04.phx.gbl>
><SBISRf$hIHA.4672@TK2MSFTNGHUB02.phx.gbl>
>>Subject: Re: SQLMetal - Problem generating VB from DBML
>>Date: Mon, 17 Mar 2008 10:50:34 -0000
>>Steven,
>>
>>The dbml file is one we 'adjust' from the normal one generated by
>SQLMetal..
>>we have to 'fix' some of the Member entries as they're badly named by
>>sqlmetal.
>>
>>Followd your link and tried to validate, but when I go to the properties
>>window in VS, it doesn't give me a 'Schema' property to select.. it just
>>gives..
>>
>>Access: Public
>>Base Class: System.Data.Linq.DataContext
>>+Connection
>>Context Namespace: MyConNS
>>Entity Namespace: MyEntNs
>>Inheritance Modifier: (None)
>>Name: DBdc
>>Serialization Mode: None
>>
>>
>>Anyway, thinking about it, it does generate the VB, it just gets some
>>columns switched around. As I said, it seems like it's not using the
>order
>>of the ThisKey and OtherKey when creating the code, but is taking the
>order
>>of the columns in the <column> elements.
>>
>>
>>
>>
>>""Steven Cheng"" <stcheng@online.microsoft.com> wrote in message
>>news:SBISRf$hIHA.4672@TK2MSFTNGHUB02.phx.gbl...
>>| Hi Adrian,
>>|
>>| As for the DBML file you provided, how did you generate it?
>>|
>>| For general validation, you can use the DBML schemas to validate the
DBML
>>| to see whether there is any XML schema specific errors. Here is the MSDN
>>| reference about this:
>>|
>>| #How to: Validate DBML and External Mapping Files (LINQ to SQL)
>>| http://msdn2.microsoft.com/en-us/library/bb882675.aspx
>>|
>>| if there doesn't exist such error. I think there may have some certain
>>| database related things cause potential problems.
>>|
>>| Sincerely,
>>|
>>| Steven Cheng
>>|
>>| Microsoft MSDN Online Support Lead
>>|
>>|
>>| Delighting our customers is our #1 priority. We welcome your comments
and
>>| suggestions about how we can improve the support we provide to you.
>Please
>>| feel free to let my manager know what you think of the level of service
>>| provided. You can send feedback directly to my manager at:
>>| msdnmg@microsoft.com.
>>|
>>| ==================================================
>>| This posting is provided "AS IS" with no warranties, and confers no
>>rights.
>>|
>>| --------------------
>>| >Reply-To: "Adrian" <apparker@nospam.nospam>
>>| >From: "Adrian" <apparker@nospam.nospam>
>>| >Subject: SQLM
>>|
>>| >I have a test DBML file:-
>>| ><?xml version="1.0" encoding="utf-8"?>
>>| ><Database Name="myDB" EntityNamespace="MyEntNS"
>>ContextNamespace="MyConNs"
>>| Class="DBdc" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
>>| > <Table Name="dbo.PARENTTABLE" Member="PARENTTABLE">
>>| > <Type Name="PARENTTABLE">
>>| > <Column Name="keycol1" Member="keycol1" Type="System.Decimal"
>>| DbType="Decimal(10,0) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
>>| > <Column Name="keycol2" Member="keycol2" Type="System.Decimal"
>>| DbType="Decimal(10,0) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
>>| > <Column Name="keycol3" Member="keycol3" Type="System.String"
>>| DbType="VarChar(10) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
>>| > <Association Name="fk_1064" Member="fkCHILDTABLE"
>>| ThisKey="keycol3,keycol1,keycol2" OtherKey="fkeycol3,fkeycol1,fkeycol2"
>>| Type="CHILDTABLE" DeleteRule="NO ACTION" />
>>| > </Type>
>>| > </Table>
>>| > <Table Name="dbo.CHILDTABLE" Member="CHILDTABLE">
>>| > <Type Name="CHILDTABLE">
>>| > <Column Name="main_id" Member="publish_id" Type="System.String"
>>| DbType="VarChar(10) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
>>| > <Column Name="fkeycol1" Member="fkeycol1" Type="System.Decimal"
>>| DbType="Decimal(10,0)" CanBeNull="true" />
>>| > <Column Name="fkeycol2" Member="fkeycol2" Type="System.Decimal"
>>| DbType="Decimal(10,0)" CanBeNull="true" />
>>| > <Column Name="fkeycol3" Member="fkeycol3" Type="System.String"
>>| DbType="VarChar(10)" CanBeNull="true" />
>>| > <Association Name="fk_1064" Member="pkPARENTTABLE"
>>| ThisKey="fkeycol3,fkeycol1,fkeycol2" OtherKey="keycol3,keycol1,keycol2"
>>| Type="PARENTTABLE" IsForeignKey="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:="fk_1064", Storage:="_pkPARENTTABLE",
>>| ThisKey:="fkeycol3,fkeycol1,fkeycol2", IsForeignKey:=true)> _
>>| > Public Property pkPARENTTABLE() As PARENTTABLE
>>| > Get
>>| > Return Me._pkPARENTTABLE.Entity
>>| > End Get
>>| > Set
>>| > Dim previousValue As PARENTTABLE = Me._pkPARENTTABLE.Entity
>>| > If ((Object.Equals(previousValue, value) = false) _
>>| > OrElse (Me._pkPARENTTABLE.HasLoadedOrAssignedValue = false))
Then
>>| > Me.SendPropertyChanging
>>| > If ((previousValue Is Nothing) _
>>| > = false) Then
>>| > Me._pkPARENTTABLE.Entity = Nothing
>>| > previousValue.fkCHILDTABLE.Remove(Me)
>>| > End If
>>| > Me._pkPARENTTABLE.Entity = value
>>| > If ((value Is Nothing) _
>>| > = false) Then
>>| > value.fkCHILDTABLE.Add(Me)
>>| > Me._fkeycol3 = value.keycol1
>>| > Me._fkeycol1 = value.keycol2
>>| > Me._fkeycol2 = value.keycol3
>>| > Else
>>| > Me._fkeycol3 = CType(Nothing, String)
>>| > Me._fkeycol1 = CType(Nothing, Nullable(Of Decimal))
>>| > Me._fkeycol2 = 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 ?
>>| >(this is using the RTM (1.00.21022) version of SQLMetal)
>>| >--
>>| >Adrian
>>| >
>>|
>>
>>
>>
>
>


Re: SQLMetal - Problem generating VB from DBML by Adrian

Adrian
Fri Mar 28 03:17:03 CDT 2008

Hi Steven,

I've now written a routine to correct the column sequence in the xml to
match the actual primary key. The code generates fine now.

"Steven Cheng [MSFT]" <stcheng@online.microsoft.com> wrote in message
news:pQdzKgwjIHA.5204@TK2MSFTNGHUB02.phx.gbl...
| Hi Adrian,
|
| I've performed some further research on this issue and consult some other
| experts on this. Some engineers from dev team told me that this is an by
| designed behavior of the LINQ DBML generation. currently, it will require
| you to keep the column orders(in your "ThisKey" and "OtherKey" ) the same
| as the column sequence in the table schema. Changing the order will make
| the generated code become mismatch on the column/fields's assignment.
|
| Sincerely,
|
| Steven Cheng
|
| Microsoft MSDN Online Support Lead
|
|
| Delighting our customers is our #1 priority. We welcome your comments and
| suggestions about how we can improve the support we provide to you. Please
| feel free to let my manager know what you think of the level of service
| provided. You can send feedback directly to my manager at:
| msdnmg@microsoft.com.
|
| This posting is provided "AS IS" with no warranties, and confers no
rights.
|
|
| --------------------
| >From: stcheng@online.microsoft.com ("Steven Cheng")
| >Organization: Microsoft
| >Date: Mon, 24 Mar 2008 09:34:34 GMT
| >Subject: Re: SQLMetal - Problem generating VB from DBML
|
| >
| >Hi Adrian,
| >
| >For the DBML document you mentioned, I've also tested it. Yes, if we keep
| >the three primary columns and their order always as 1, 2, 3 in all
| places,
| >it will generate code as expected. However, if we change the order as
| >below(in your customized DBML):
| >
| >ThisKey="keycol3,keycol1,keycol2" OtherKey="fkeycol3,fkeycol1,fkeycol2"
| >
| >the code it generate does seem different between the columns order in
| >DBML. I'll do some further research to see whether there is anything
which
| >can control this.
| >
| >Sincerely,
| >
| >Steven Cheng
| >
| >Microsoft MSDN Online Support Lead
| >
| >
| >Delighting our customers is our #1 priority. We welcome your comments and
| >suggestions about how we can improve the support we provide to you.
Please
| >feel free to let my manager know what you think of the level of service
| >provided. You can send feedback directly to my manager at:
| >msdnmg@microsoft.com.
| >
| >This posting is provided "AS IS" with no warranties, and confers no
rights.
| >
| >
| >
| >--------------------
| >>Reply-To: "Adrian" <apparker@nospam.nospam>
| >>From: "Adrian" <apparker@nospam.nospam>
| >>References: <uPcn4ddhIHA.748@TK2MSFTNGP04.phx.gbl>
| ><SBISRf$hIHA.4672@TK2MSFTNGHUB02.phx.gbl>
| >>Subject: Re: SQLMetal - Problem generating VB from DBML
| >>Date: Mon, 17 Mar 2008 10:50:34 -0000
| >>Steven,
| >>
| >>The dbml file is one we 'adjust' from the normal one generated by
| >SQLMetal..
| >>we have to 'fix' some of the Member entries as they're badly named by
| >>sqlmetal.
| >>
| >>Followd your link and tried to validate, but when I go to the properties
| >>window in VS, it doesn't give me a 'Schema' property to select.. it just
| >>gives..
| >>
| >>Access: Public
| >>Base Class: System.Data.Linq.DataContext
| >>+Connection
| >>Context Namespace: MyConNS
| >>Entity Namespace: MyEntNs
| >>Inheritance Modifier: (None)
| >>Name: DBdc
| >>Serialization Mode: None
| >>
| >>
| >>Anyway, thinking about it, it does generate the VB, it just gets some
| >>columns switched around. As I said, it seems like it's not using the
| >order
| >>of the ThisKey and OtherKey when creating the code, but is taking the
| >order
| >>of the columns in the <column> elements.
| >>
| >>
| >>
| >>
| >>""Steven Cheng"" <stcheng@online.microsoft.com> wrote in message
| >>news:SBISRf$hIHA.4672@TK2MSFTNGHUB02.phx.gbl...
| >>| Hi Adrian,
| >>|
| >>| As for the DBML file you provided, how did you generate it?
| >>|
| >>| For general validation, you can use the DBML schemas to validate the
| DBML
| >>| to see whether there is any XML schema specific errors. Here is the
MSDN
| >>| reference about this:
| >>|
| >>| #How to: Validate DBML and External Mapping Files (LINQ to SQL)
| >>| http://msdn2.microsoft.com/en-us/library/bb882675.aspx
| >>|
| >>| if there doesn't exist such error. I think there may have some certain
| >>| database related things cause potential problems.
| >>|
| >>| Sincerely,
| >>|
| >>| Steven Cheng
| >>|
| >>| Microsoft MSDN Online Support Lead
| >>|
| >>|
| >>| Delighting our customers is our #1 priority. We welcome your comments
| and
| >>| suggestions about how we can improve the support we provide to you.
| >Please
| >>| feel free to let my manager know what you think of the level of
service
| >>| provided. You can send feedback directly to my manager at:
| >>| msdnmg@microsoft.com.
| >>|
| >>| ==================================================
| >>| This posting is provided "AS IS" with no warranties, and confers no
| >>rights.
| >>|
| >>| --------------------
| >>| >Reply-To: "Adrian" <apparker@nospam.nospam>
| >>| >From: "Adrian" <apparker@nospam.nospam>
| >>| >Subject: SQLM
| >>|
| >>| >I have a test DBML file:-
| >>| ><?xml version="1.0" encoding="utf-8"?>
| >>| ><Database Name="myDB" EntityNamespace="MyEntNS"
| >>ContextNamespace="MyConNs"
| >>| Class="DBdc" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
| >>| > <Table Name="dbo.PARENTTABLE" Member="PARENTTABLE">
| >>| > <Type Name="PARENTTABLE">
| >>| > <Column Name="keycol1" Member="keycol1" Type="System.Decimal"
| >>| DbType="Decimal(10,0) NOT NULL" IsPrimaryKey="true" CanBeNull="false"
/>
| >>| > <Column Name="keycol2" Member="keycol2" Type="System.Decimal"
| >>| DbType="Decimal(10,0) NOT NULL" IsPrimaryKey="true" CanBeNull="false"
/>
| >>| > <Column Name="keycol3" Member="keycol3" Type="System.String"
| >>| DbType="VarChar(10) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
| >>| > <Association Name="fk_1064" Member="fkCHILDTABLE"
| >>| ThisKey="keycol3,keycol1,keycol2"
OtherKey="fkeycol3,fkeycol1,fkeycol2"
| >>| Type="CHILDTABLE" DeleteRule="NO ACTION" />
| >>| > </Type>
| >>| > </Table>
| >>| > <Table Name="dbo.CHILDTABLE" Member="CHILDTABLE">
| >>| > <Type Name="CHILDTABLE">
| >>| > <Column Name="main_id" Member="publish_id" Type="System.String"
| >>| DbType="VarChar(10) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
| >>| > <Column Name="fkeycol1" Member="fkeycol1" Type="System.Decimal"
| >>| DbType="Decimal(10,0)" CanBeNull="true" />
| >>| > <Column Name="fkeycol2" Member="fkeycol2" Type="System.Decimal"
| >>| DbType="Decimal(10,0)" CanBeNull="true" />
| >>| > <Column Name="fkeycol3" Member="fkeycol3" Type="System.String"
| >>| DbType="VarChar(10)" CanBeNull="true" />
| >>| > <Association Name="fk_1064" Member="pkPARENTTABLE"
| >>| ThisKey="fkeycol3,fkeycol1,fkeycol2"
OtherKey="keycol3,keycol1,keycol2"
| >>| Type="PARENTTABLE" IsForeignKey="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:="fk_1064", Storage:="_pkPARENTTABLE",
| >>| ThisKey:="fkeycol3,fkeycol1,fkeycol2", IsForeignKey:=true)> _
| >>| > Public Property pkPARENTTABLE() As PARENTTABLE
| >>| > Get
| >>| > Return Me._pkPARENTTABLE.Entity
| >>| > End Get
| >>| > Set
| >>| > Dim previousValue As PARENTTABLE = Me._pkPARENTTABLE.Entity
| >>| > If ((Object.Equals(previousValue, value) = false) _
| >>| > OrElse (Me._pkPARENTTABLE.HasLoadedOrAssignedValue = false))
| Then
| >>| > Me.SendPropertyChanging
| >>| > If ((previousValue Is Nothing) _
| >>| > = false) Then
| >>| > Me._pkPARENTTABLE.Entity = Nothing
| >>| > previousValue.fkCHILDTABLE.Remove(Me)
| >>| > End If
| >>| > Me._pkPARENTTABLE.Entity = value
| >>| > If ((value Is Nothing) _
| >>| > = false) Then
| >>| > value.fkCHILDTABLE.Add(Me)
| >>| > Me._fkeycol3 = value.keycol1
| >>| > Me._fkeycol1 = value.keycol2
| >>| > Me._fkeycol2 = value.keycol3
| >>| > Else
| >>| > Me._fkeycol3 = CType(Nothing, String)
| >>| > Me._fkeycol1 = CType(Nothing, Nullable(Of Decimal))
| >>| > Me._fkeycol2 = 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 ?
| >>| >(this is using the RTM (1.00.21022) version of SQLMetal)
| >>| >--
| >>| >Adrian
| >>| >
| >>|
| >>
| >>
| >>
| >
| >
|



Re: SQLMetal - Problem generating VB from DBML by stcheng

stcheng
Fri Mar 28 04:40:42 CDT 2008

Hi Adrian,

Thanks for your reply and inform us of the result.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

--------------------
>Reply-To: "Adrian" <apparker@nospam.nospam>
>From: "Adrian" <apparker@nospam.nospam>
>Subject: Re: SQLMetal - Problem generating VB from DBML
>Date: Fri, 28 Mar 2008 08:17:03 -0000
>
>Hi Steven,
>
>I've now written a routine to correct the column sequence in the xml to
>match the actual primary key. The code generates fine now.
>
>"Steven Cheng [MSFT]" <stcheng@online.microsoft.com> wrote in message
>news:pQdzKgwjIHA.5204@TK2MSFTNGHUB02.phx.gbl...
>| Hi Adrian,
>|
>| I've performed some further research on this issue and consult some other
>| experts on this. Some engineers from dev team told me that this is an by
>| designed behavior of the LINQ DBML generation. currently, it will require
>| you to keep the column orders(in your "ThisKey" and "OtherKey" ) the same
>| as the column sequence in the table schema. Changing the order will make
>| the generated code become mismatch on the column/fields's assignment.
>|
>| Sincerely,
>|
>| Steven Cheng
>|
>| Microsoft MSDN Online Support Lead
>|
>|
>| Delighting our customers is our #1 priority. We welcome your comments and
>| suggestions about how we can improve the support we provide to you.
Please
>| feel free to let my manager know what you think of the level of service
>| provided. You can send feedback directly to my manager at:
>| msdnmg@microsoft.com.
>|
>| This posting is provided "AS IS" with no warranties, and confers no
>rights.
>|
>|
>| --------------------
>| >From: stcheng@online.microsoft.com ("Steven Cheng")
>| >Organization: Microsoft
>| >Date: Mon, 24 Mar 2008 09:34:34 GMT
>| >Subject: Re: SQLMetal - Problem generating VB from DBML
>|
>| >
>| >Hi Adrian,
>| >
>| >For the DBML document you mentioned, I've also tested it. Yes, if we
keep
>| >the three primary columns and their order always as 1, 2, 3 in all
>| places,
>| >it will generate code as expected. However, if we change the order as
>| >below(in your customized DBML):
>| >
>| >ThisKey="keycol3,keycol1,keycol2" OtherKey="fkeycol3,fkeycol1,fkeycol2"
>| >
>| >the code it generate does seem different between the columns order in
>| >DBML. I'll do some further research to see whether there is anything
>which
>| >can control this.
>| >
>| >Sincerely,
>| >
>| >Steven Cheng
>| >
>| >Microsoft MSDN Online Support Lead
>| >
>| >
>| >Delighting our customers is our #1 priority. We welcome your comments
and
>| >suggestions about how we can improve the support we provide to you.
>Please
>| >feel free to let my manager know what you think of the level of service
>| >provided. You can send feedback directly to my manager at:
>| >msdnmg@microsoft.com.
>| >
>| >This posting is provided "AS IS" with no warranties, and confers no
>rights.
>| >
>| >
>| >
>| >--------------------
>| >>Reply-To: "Adrian" <apparker@nospam.nospam>
>| >>From: "Adrian" <apparker@nospam.nospam>
>| >>References: <uPcn4ddhIHA.748@TK2MSFTNGP04.phx.gbl>
>| ><SBISRf$hIHA.4672@TK2MSFTNGHUB02.phx.gbl>
>| >>Subject: Re: SQLMetal - Problem generating VB from DBML
>| >>Date: Mon, 17 Mar 2008 10:50:34 -0000
>| >>Steven,
>| >>
>| >>The dbml file is one we 'adjust' from the normal one generated by
>| >SQLMetal..
>| >>we have to 'fix' some of the Member entries as they're badly named by
>| >>sqlmetal.
>| >>
>| >>Followd your link and tried to validate, but when I go to the
properties
>| >>window in VS, it doesn't give me a 'Schema' property to select.. it
just
>| >>gives..
>| >>
>| >>Access: Public
>| >>Base Class: System.Data.Linq.DataContext
>| >>+Connection
>| >>Context Namespace: MyConNS
>| >>Entity Namespace: MyEntNs
>| >>Inheritance Modifier: (None)
>| >>Name: DBdc
>| >>Serialization Mode: None
>| >>
>| >>
>| >>Anyway, thinking about it, it does generate the VB, it just gets some
>| >>columns switched around. As I said, it seems like it's not using the
>| >order
>| >>of the ThisKey and OtherKey when creating the code, but is taking the
>| >order
>| >>of the columns in the <column> elements.
>| >>
>| >>
>| >>
>| >>
>| >>""Steven Cheng"" <stcheng@online.microsoft.com> wrote in message
>| >>news:SBISRf$hIHA.4672@TK2MSFTNGHUB02.phx.gbl...
>| >>| Hi Adrian,
>| >>|
>| >>| As for the DBML file you provided, how did you generate it?
>| >>|
>| >>| For general validation, you can use the DBML schemas to validate the
>| DBML
>| >>| to see whether there is any XML schema specific errors. Here is the
>MSDN
>| >>| reference about this:
>| >>|
>| >>| #How to: Validate DBML and External Mapping Files (LINQ to SQL)
>| >>| http://msdn2.microsoft.com/en-us/library/bb882675.aspx
>| >>|
>| >>| if there doesn't exist such error. I think there may have some
certain
>| >>| database related things cause potential problems.
>| >>|
>| >>| Sincerely,
>| >>|
>| >>| Steven Cheng
>| >>|
>| >>| Microsoft MSDN Online Support Lead
>| >>|
>| >>|
>| >>| Delighting our customers is our #1 priority. We welcome your comments
>| and
>| >>| suggestions about how we can improve the support we provide to you.
>| >Please
>| >>| feel free to let my manager know what you think of the level of
>service
>| >>| provided. You can send feedback directly to my manager at:
>| >>| msdnmg@microsoft.com.
>| >>|
>| >>| ==================================================
>| >>| This posting is provided "AS IS" with no warranties, and confers no
>| >>rights.
>| >>|
>| >>| --------------------
>| >>| >Reply-To: "Adrian" <apparker@nospam.nospam>
>| >>| >From: "Adrian" <apparker@nospam.nospam>
>| >>| >Subject: SQLM
>| >>|
>| >>| >I have a test DBML file:-
>| >>| ><?xml version="1.0" encoding="utf-8"?>
>| >>| ><Database Name="myDB" EntityNamespace="MyEntNS"
>| >>ContextNamespace="MyConNs"
>| >>| Class="DBdc"
xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
>| >>| > <Table Name="dbo.PARENTTABLE" Member="PARENTTABLE">
>| >>| > <Type Name="PARENTTABLE">
>| >>| > <Column Name="keycol1" Member="keycol1" Type="System.Decimal"
>| >>| DbType="Decimal(10,0) NOT NULL" IsPrimaryKey="true"
CanBeNull="false"
>/>
>| >>| > <Column Name="keycol2" Member="keycol2" Type="System.Decimal"
>| >>| DbType="Decimal(10,0) NOT NULL" IsPrimaryKey="true"
CanBeNull="false"
>/>
>| >>| > <Column Name="keycol3" Member="keycol3" Type="System.String"
>| >>| DbType="VarChar(10) NOT NULL" IsPrimaryKey="true" CanBeNull="false"
/>
>| >>| > <Association Name="fk_1064" Member="fkCHILDTABLE"
>| >>| ThisKey="keycol3,keycol1,keycol2"
>OtherKey="fkeycol3,fkeycol1,fkeyc