Problem with association insert

Thread is closed for posting
4 posts, 0 answers
  1. Patrick
    Patrick avatar
    14 posts
    Member since:
    Feb 2011

    Posted 03 Mar 2011 Link to this post


    from the documentation 

    Car newCar = new Car();
    newCar.ABS = true;
    newCar.AirConditioner = true;
    newCar.ASR = true;
    newCar.Available = false;
    newCar.CarYear = 2012;
    newCar.DVDPlayer = false;
    newCar.Make = "Audi";
    newCar.Model = "A8";
    newCar.Mp3Player = true;
    newCar.Navigation = false;
    newCar.TagNumber = "PB 3341 SS";
    Category newCategory = new Category();
    newCategory.CategoryName = "MyCategory";

    my code:

    Print p = new Print();                         
    p.LocationID = loc.ID;
    p.Timestamp = DateTime.Now;

    everything gets inserted into my database (sql 2005)
    EXCEPT the JobID in my Print table. JobID is still null.
    Is there something i need to set before SaveChanges?

    thanks for help

    UPDATE: Found the solutions some posts below. Thread can be closed
  2. gmendez
    gmendez avatar
    82 posts
    Member since:
    Jun 2012

    Posted 30 Sep 2011 Link to this post

    Hi Patrick!! Would you point me to the post where you found the solution please?

  3. Ivailo
    Ivailo avatar
    318 posts

    Posted 05 Oct 2011 Link to this post

    Hi Gonzalo,

    The solution for this problem is setting the IsManaged property of the association to True - in Patrick's case that is the association between Job and Print Domain Classes.

    For more information regarding IsManaged, it is described as a property and in the context of working with data (one-to-many relationships section) in our documentation.
    Do not hesitate to contact us if you need further clarifications on this functionality.

    Best wishes,
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

  4. gmendez
    gmendez avatar
    82 posts
    Member since:
    Jun 2012

    Posted 05 Oct 2011 Link to this post

    That worked perfectly.
    Thank you very much for your (as always) valuable help.

Back to Top