I m new in Linq and i didnt understang this query
Db.Enum_Countries .Where(p=>p.id==id)
.Single()
.Title)
Can you help me....
I m new in Linq and i didnt understang this query
Db.Enum_Countries .Where(p=>p.id==id)
.Single()
.Title)
Can you help me....
Where(...)
finds all the countries with the given id. Single(...)
ensures that only one country has that id, and returns just that country.
In summary, it means, "The title of the only country whose id is id
".
You have a list of things -- presumably countries -- which have a Title
property. You want to find the single item in that list whose id
property matches the id
variable you have in scope. Then you want to access its Title
property.
You could also write:
db.Enum_Countries.Single(p => p.id == id).Title