Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand your question correctly, given a List you could use linq to grab a single employee.</p> <pre><code>EmployeeInfo singleEmployee = employee.Where( x =&gt; x.Id).SingleOrDefault(); if (singleEmployee != null) { do something here } </code></pre> <p>that said, I don't know if you have a 'key' against the employee like Id or similar.</p> <p>To get by index, you have a bigger round trip (outputting the emploees to a grid or something similar, allowing a click that passes in the index of the employee you want, and access the single eployee that way).</p> <p>Unless you're heavily employing caching in the 'EmployeeInfoProxy.GetAllEmployeeInfo()' method though, I'd say you want a 'GetEmployeeInfoById()' and again, I'll harp back to the need for your EmployeeInfo to have a unique Id of some description - you will make your life so much easier.</p> <p>Hope this helps. Cheers, Terry</p> <p>[in addition] if employeeListInfo has 3 entries, then to access each of them I'd say the best way would be to create a viewmodel (it looks like this is MVC), but worst case scenario you could do:</p> <pre><code>List&lt;EmployeeInfo&gt; employee = new List&lt;EmployeeInfo&gt;(employeeInfoList.Values); ViewData["Employees"] = employee; </code></pre> <p>then in your view, just do:</p> <pre><code>&lt;% foreach(EmployeeInfo employeeDetails in ViewData["Employees"] as List&lt;EmployeeInfo&gt;) { %&gt; &lt;!-- you will be looping through each employee here, so you can do as you wish &lt;% } %&gt; </code></pre> <p>I wouldn't say this is best practice - using a ViewModel would likely represent a better way to do this, though the above will certainly give you a solution that will work in your case.</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.
 

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