This is a migrated thread and some comments may be shown as answers.

Persist graph

2 Answers 44 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Federiko
Top achievements
Rank 1
Federiko asked on 30 Mar 2012, 02:23 PM
Hi everyone,
I can't find the solution for the following problem..
I have Three Classes, all this making the reverse mapping and all the Id are identity in the tables.

-Ticket
 Id
 Name

-ItemInTicket
 Id
 TicketId
 ItemId
 Quantity

-ProfessionalInTicket
 Id
 TicketId
 ProfessionalId
 Approved

When I try to make this:

var oTicket = new Ticket();
oTicket.Name =
"Problem";

var oItem =
new ItemInTicket();
oItem.ItemId = 8;
oItem.Quantity = 10;
oTicket.Items.Add(oItem);

var oProfessional =
new ProfessionalInTicket();
oProfesional.ProfessionalId = 2;
oProfesional.Approved =
true;
oTicket.Professionals.Add(oProfessional);

_context.Add(oTiket);
_context.SaveChanges()



And I get a exception with the id from Ticket in ItemInTicket and ProfessionalInTicket.
Sql Server Profiler show me that the Ticket insert is done but when try to insert ItemInTicket the Id of TicketId is 0.
Could someone help me on this.
Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Federiko
Top achievements
Rank 1
answered on 30 Mar 2012, 03:07 PM
Problem Solve!
Thanks!!!
0
Ivailo
Telerik team
answered on 30 Mar 2012, 03:22 PM
Hi Federiko,

Thanks for your interest in OpenAccess ORM. We are glad that your issue was resolved.

Do not hesitate to get back to us if you have any other questions or issues.

All the best,
Ivailo
the Telerik team
Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
Tags
General Discussions
Asked by
Federiko
Top achievements
Rank 1
Answers by
Federiko
Top achievements
Rank 1
Ivailo
Telerik team
Share this question
or