Insert into related data entity

Thread is closed for posting
3 posts, 0 answers
  1. Issam
    Issam avatar
    18 posts
    Member since:
    Sep 2008

    Posted 02 Mar 2014 Link to this post

    i load a patient record with this query

    FetchStrategy fetchStrategy = new FetchStrategy();
              fetchStrategy.LoadWith<PATIENT>(c => c.CONSULTATIONs);
              fetchStrategy.LoadWith<PATIENT>(c => c.ANTECEDANTs);
              fetchStrategy.LoadWith<PATIENT>(c => c.ALERGIES_PATIENTs);
              fetchStrategy.LoadWith<PATIENT>(c => c.PATIENTS_MEDECINs);
              IQueryable<PATIENT> dossier = from pat in _context.PATIENTs.
              Where(x => x.ID_PATIENT == p.ID_PATIENT).
              select pat;

    so basically i load a single patient record with all related childs entities

    in my form i have some listboxes attached to the related entity data, and it seems to works .

    Now i cannot figure out how to insert data for example to the CONSULTATIONs entity since the type is not recognized as it, but as Piece'1Tracked or something like . and the dossier instance is no more of type PATIENT but of type Piece'1

    i have tested with messagebox GetType().Name, and a cast to PATIENT type gave me an exception

    any help is welcome

    thanks and good day

  2. Issam
    Issam avatar
    18 posts
    Member since:
    Sep 2008

    Posted 03 Mar 2014 Link to this post

    i think that i have found it !

    ((IQueryable<PATIENT>)DataContext).FirstOrDefault().CONSULTATIONs. .......
  3. Ady
    Ady avatar
    589 posts

    Posted 05 Mar 2014 Link to this post

    Hi Issam,

     Yes, you need to get select a single object (via First() or Single() extension methods) from the IQueryable in order to be able to work against it.

    Do get back in case you need further assistance.

    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
Back to Top