new new association

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
hepek
Posts: 115
Joined: Thu 07 Jul 2011 13:59

new new association

Post by hepek » Fri 02 May 2014 16:43

I understand it is not possible to create relation if the two columns do not match.

I have table 1 containing column DOCUMENT_ID NUMBER NOT NULL
table 2 has the same column but this column is NULLABLE

devart would not let me create relation between two tables since the seconds column is specified as NULLABLE.

Is there any way around?
I cannot change the database structure since other applications are using it.

thanks
Nermin

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: new new association

Post by MariiaI » Mon 05 May 2014 10:20

You are working with a LinqConnect model and trying to add a 1-to-1 association, aren't you?
If yes, then the possibility to add 1-to-1 associations with nullable foreign key properties was added in LinqConnect 4.2.306/dotConnect for Oracle 7.8.301 (released on 08-Aug-13):
http://forums.devart.com/viewtopic.php?f=1&t=27701.

If it is your case, please upgrade your dotConnect for Oracle to a newer one.

hepek
Posts: 115
Joined: Thu 07 Jul 2011 13:59

Re: new new association

Post by hepek » Mon 05 May 2014 14:00

thank you

hepek
Posts: 115
Joined: Thu 07 Jul 2011 13:59

Re: new new association

Post by hepek » Mon 05 May 2014 14:54

I have another question.

I imported a table definition in diagram (.lqlml) by pasting XML like indicated below.
I run a custom tool on my diagram and it did create this entity.
However - I can't find this entity in a diagram, I mean I can find it when I do the search, but the entity itself does not show up in diagram. I can access this entity, intelisense is working fine and all that - but it does not show in a diagram. I have dotConnect version 7.7.267

Please advice.
thank you

Code: Select all

  <Table Name="OPL.ESP_EDGAR_DOCUMENTS" Member="EspEdgarDocuments">
    <Type Name="EspEdgarDocument" ed:Guid="953b0167-b067-485a-b6eb-b75505022007">
      <Column Name="DOCUMENT_ID" Member="DocumentId" Type="System.Int64" DbType="NUMBER(16) NOT NULL" IsPrimaryKey="true" CanBeNull="false" Precision="16" ed:ValidateRequired="True" ed:Guid="0863a945-571f-4de2-9d4a-40a91ad9e457" />
      <Column Name="SUBMISSION_TYPE_ID" Member="SubmissionTypeId" Type="System.Int32" DbType="NUMBER(3) NULL" CanBeNull="true" UpdateCheck="Never" Precision="3" ed:ValidateRequired="False" ed:Guid="f01aa5a9-96ab-4514-8eba-79c7951a48e2" />
    </Type>
  </Table>

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: new new association

Post by MariiaI » Tue 06 May 2014 07:07

Please open Model Explorer-> YourDataContext-> Classes and:
- drag the "EspEdgarDocument" class on the diagram
or
- right-click the "EspEdgarDocument" class and select "Add On Diagram" from the shortcut menu.

hepek
Posts: 115
Joined: Thu 07 Jul 2011 13:59

Re: new new association

Post by hepek » Tue 06 May 2014 14:24

thank you

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: new new association

Post by MariiaI » Wed 07 May 2014 07:13

If you have any further questions, feel free to contact us.

hepek
Posts: 115
Joined: Thu 07 Jul 2011 13:59

Re: new new association

Post by hepek » Wed 07 May 2014 13:33

I do have another question.

I need to create a "clone row" functionality. For example I have table called JOB, and I want to clone one job to another. First I need to retrieve the original record from database, change the primary key and insert new record in back to database.

Of course dotConnect would not let me do this, since it has a self-tracking feature.
It won't let me change the primary key.

is there a way to detach entity once retrieved from database, so I could just change pk for the records and insert in into database as new record?

thanks

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: new new association

Post by MariiaI » Thu 08 May 2014 11:14

is there a way to detach entity once retrieved from database, so I could just change pk for the records and insert in into database as new record?
It is impossible to detach objects from the DataContext, please refer to: http://www.devart.com/linqconnect/docs/?attach.html

You can try using this code to implement your scenario:

Code: Select all

SCOTTContext.SCOTTDataContext dt = new SCOTTContext.SCOTTDataContext();
SCOTTContext.DEPT entOld = dt.DEPTs.First();

SCOTTContext.SCOTTDataContext dt2 = new SCOTTContext.SCOTTDataContext() { Log = Console.Out };
SCOTTContext.DEPT entNew = entOld;
entNew.DEPTNO = 10;// new id
dt2.DEPTs.InsertOnSubmit(entNew);
dt2.SubmitChanges();
If you have any further questions, feel free to contact us.

hepek
Posts: 115
Joined: Thu 07 Jul 2011 13:59

Re: new new association

Post by hepek » Thu 08 May 2014 13:44

thank you

Post Reply