Oracle DataTable and PrimaryKey
Oracle DataTable and PrimaryKey
The DevArt DataSet Desingner does not generates a PrimaryKey of the datatables. Instead is adds a unique constraint.
This causes that the merge method does not work, because this is based on the primaryKey property.
I am using version 5.20.33.0
This is the generated code of the InitClass():
.....
this.columnIdProvincia = new System.Data.DataColumn("IdProvincia", typeof(int), null, System.Data.MappingType.Element);
base.Columns.Add(this.columnIdProvincia);
this.columnNombre = new System.Data.DataColumn("Nombre", typeof(string), null, System.Data.MappingType.Element);
base.Columns.Add(this.columnNombre);
this.columnNemonico = new System.Data.DataColumn("Nemonico", typeof(string), null, System.Data.MappingType.Element);
base.Columns.Add(this.columnNemonico);
this.columnNombreMEG = new System.Data.DataColumn("NombreMEG", typeof(string), null, System.Data.MappingType.Element);
base.Columns.Add(this.columnNombreMEG);
this.Constraints.Add(new System.Data.UniqueConstraint("Constraint1", new System.Data.DataColumn[] {
this.columnIdProvincia}, false)); <-----Here it should be true, because it is a Primary Key
this.columnIdProvincia.AllowDBNull = false;
this.columnIdProvincia.Unique = true;
.......
This causes that the merge method does not work, because this is based on the primaryKey property.
I am using version 5.20.33.0
This is the generated code of the InitClass():
.....
this.columnIdProvincia = new System.Data.DataColumn("IdProvincia", typeof(int), null, System.Data.MappingType.Element);
base.Columns.Add(this.columnIdProvincia);
this.columnNombre = new System.Data.DataColumn("Nombre", typeof(string), null, System.Data.MappingType.Element);
base.Columns.Add(this.columnNombre);
this.columnNemonico = new System.Data.DataColumn("Nemonico", typeof(string), null, System.Data.MappingType.Element);
base.Columns.Add(this.columnNemonico);
this.columnNombreMEG = new System.Data.DataColumn("NombreMEG", typeof(string), null, System.Data.MappingType.Element);
base.Columns.Add(this.columnNombreMEG);
this.Constraints.Add(new System.Data.UniqueConstraint("Constraint1", new System.Data.DataColumn[] {
this.columnIdProvincia}, false)); <-----Here it should be true, because it is a Primary Key
this.columnIdProvincia.AllowDBNull = false;
this.columnIdProvincia.Unique = true;
.......
I have generated DataSets using dotConnect for Oracle v 5.20.33 with both generators:
1) the Data > Add New Data Source menu of Visual Studio;
2) Tools > Oracle > DataSet Wizard.
The result is the same:
this.Constraints.Add(new System.Data.UniqueConstraint("Constraint1", new System.Data.DataColumn[] {
this.columnIdProvincia}, true));
My test table:
CREATE TABLE DEPT (
DEPTNO NUMBER(2),
DNAME VARCHAR2(14),
LOC VARCHAR2(13),
CONSTRAINT PK_DEPT PRIMARY KEY (DEPTNO))
Please give us the following information:
1) which generator you are using;
2) does the problem persist with the DEPT table in your environment? If not, please post here the DDL script of your table to reproduce the issue.
1) the Data > Add New Data Source menu of Visual Studio;
2) Tools > Oracle > DataSet Wizard.
The result is the same:
this.Constraints.Add(new System.Data.UniqueConstraint("Constraint1", new System.Data.DataColumn[] {
this.columnIdProvincia}, true));
My test table:
CREATE TABLE DEPT (
DEPTNO NUMBER(2),
DNAME VARCHAR2(14),
LOC VARCHAR2(13),
CONSTRAINT PK_DEPT PRIMARY KEY (DEPTNO))
Please give us the following information:
1) which generator you are using;
2) does the problem persist with the DEPT table in your environment? If not, please post here the DDL script of your table to reproduce the issue.
I think i found the bug. If you generate the dataset for the first time you have no problem and it works fine, but when you want to modified it, by selecting an existing dataSet, you get the mentioned error.
To reproduce it follow the steps:
1)Open the DataSetWizard and add a new dataset and add only the Dept table.
2)Generate the dataSet
3)Open again the DataSetWizard and select the previous generated dataSet.
4)Don't change anything, simply press next.
If you look at the generated code after step 2 you will see this,
private void InitClass() {
.......
this.Constraints.Add(new System.Data.UniqueConstraint("Constraint1", new System.Data.DataColumn[] {
this.columnDEPTNO}, true)); <---OK!!!!
.......
}
But if you modify the dataset (actually i didnt change anything) you should see this
private void InitClass() {
.......
this.Constraints.Add(new System.Data.UniqueConstraint("Constraint1", new System.Data.DataColumn[] {
this.columnDEPTNO}, false));<---IT SHOULD BE TRUE!!!!!
.......
}
It is urgent to find a solution to this. Thanks
To reproduce it follow the steps:
1)Open the DataSetWizard and add a new dataset and add only the Dept table.
2)Generate the dataSet
3)Open again the DataSetWizard and select the previous generated dataSet.
4)Don't change anything, simply press next.
If you look at the generated code after step 2 you will see this,
private void InitClass() {
.......
this.Constraints.Add(new System.Data.UniqueConstraint("Constraint1", new System.Data.DataColumn[] {
this.columnDEPTNO}, true)); <---OK!!!!
.......
}
But if you modify the dataset (actually i didnt change anything) you should see this
private void InitClass() {
.......
this.Constraints.Add(new System.Data.UniqueConstraint("Constraint1", new System.Data.DataColumn[] {
this.columnDEPTNO}, false));<---IT SHOULD BE TRUE!!!!!
.......
}
It is urgent to find a solution to this. Thanks
New build of dotConnect for Oracle 6.60.268 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=22977 .
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=22977 .