Persist graph

3 posts, 0 answers
  1. Federiko
    Federiko avatar
    2 posts
    Member since:
    Feb 2012

    Posted 30 Mar 2012 Link to this post

    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. Federiko
    Federiko avatar
    2 posts
    Member since:
    Feb 2012

    Posted 30 Mar 2012 Link to this post

    Problem Solve!
    Thanks!!!
  3. DevCraft banner
  4. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 30 Mar 2012 Link to this post

    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 >>
Back to Top