I have a list which has a single record i.e which matches to a particular ID.
Now I want to use this list’s property(i.e. a column for that single record) without using FOREACH loop as it will just cause burden for server because my program is already having lot of loops…
Can it be done??
I am filtering the records brought from ViewState based on an ID..
var selectedPracticeInfo =
(List<PropPractice>) ViewState["dicPracticesInGrupWithTimeZone"];
var selectedPracticeforEncounter =
from selectedPractice in selectedPracticeInfo
where
selectedPractice.PracticeId
== Convert.ToInt32(ddlPractice.SelectedValue)
select new PropPractice
{
PracticeId = selectedPractice.PracticeId,
PracticeName = selectedPractice.PracticeName,
TimeZoneDisplayName = selectedPractice.TimeZoneDisplayName
};
I am planning to do something like this which will pull out the TimeZoneDisplayName of that Single record directly but it says “String cannot be used as Boolean”..
var practiceTimeZoneName
= selectedPracticeforEncounter
.Single(practice=>practice.TimeZoneDisplayName
So,I wanted to ask if it can be done by some way except FOREACH??
Is this something like you require? First Or Default will ensure you get a single record or null
result will be a type of PropPractice but for good practice use strongly defined where you can
you will not need the below to create the new object: