Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I write the Linq query to get complex model items?
    primarykey
    data
    text
    <p>I'm using EF Code First. Now, I'm having a hard time figuring out how to write the LINQ to retrieve the data into my models in my Controller, to display them in a view. Basically, I am receiving a feed of HolterTest data, and I am trying to create a worklist for the people who do a bunch of specific tasks to process the HolterTest, allowing them to flag the tasks as they are completed, and provide status of where the individual tests are in the process The basic Task class is so they can add or alter steps in the process, with the displayOrder being the order in which tasks are done. A WorkTask is a specific instance of a task, allowing us to mark who completed it, and when. A WorkItem is the complex type that includes the HolterTest, the list of WorkTasks, and status information, including when the WorkTasks were all completed.</p> <p>Model Classes:</p> <pre><code>public class HolterTest { public Int32 HolterTestID { get; set; } public string PatientNumber { get; set; } public string LastName { get; set; } public DateTime RecordingStartDateTime { get; set; } public System.Nullable&lt;DateTime&gt; AppointmentDateTime { get; set; } } public class Task { public Int32 TaskID { get; set; } public string Name { get; set; } public string Description { get; set; } public Int32 DisplayOrder { get; set; } public bool IsActive { get; set; } } public class WorkTask { public Int32 WorkTaskID { get; set; } public Task Task { get; set; } public bool IsCompleted { get; set; } public System.Nullable&lt;DateTime&gt; CompletedDateTime { get; set; } public string CompletedBy { get; set; } } public class WorkItem { public Int32 WorkItemID { get; set; } public HolterTest HolterTest { get; set; } public string Status { get; set; } public List&lt;WorkTask&gt; WorkTasks { get; set; } public bool IsStarted { get; set; } public bool IsCompleted { get; set; } public System.Nullable&lt;DateTime&gt; CompletedDateTime { get; set; } } </code></pre> <p>Currently I have a business logic function that takes the list of HolterTests, finds the ones that don't have a WorkItem, and creates the WorkItems, associates the HolterTests including the WorkTasks, based on the current active list of Tasks.</p> <p>My problem is how to write the LINQ to get all of the WorkItems (with their child items) for my WorkItemController so I can display the work to do in a View (WorkItems where IsCompleted = false) by PatientNumber, and make it possible to update WorkTasks for a particular WorkItem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload