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

Insert into related data entity

2 Answers 48 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Issam
Top achievements
Rank 1
Issam asked on 02 Mar 2014, 06:53 PM
Hi,
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).
          LoadWith(fetchStrategy)
          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 Answers, 1 is accepted

Sort by
0
Issam
Top achievements
Rank 1
answered on 04 Mar 2014, 02:12 AM
i think that i have found it !

((IQueryable<PATIENT>)DataContext).FirstOrDefault().CONSULTATIONs. .......
0
Ady
Telerik team
answered on 05 Mar 2014, 03:40 PM
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.

Regards,
Ady
Telerik
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
Tags
Getting Started
Asked by
Issam
Top achievements
Rank 1
Answers by
Issam
Top achievements
Rank 1
Ady
Telerik team
Share this question
or