Retrieving a single value from a single column in a single row?
Is there some simple way to reference a single value from a single column in a single row of a LINQ result set? I don't want to bind it to a control. I don't want to iterate through every row in the set. I just want the equivalent of this:
dim strTemp as string = datatable.row(0)("FieldName")
You can use projection to select only the "column" or property of an object. You can then use FirstOrDefault (or First) to only get a single value. The following code would store Ron in the singleFirstName.FirstName variable:
You can also assign it to a string variable directly by just selecting the FirstName field, like this:
Hope this helps,
Right on the first response, as always, Imar! I knew there had to be a simple answer, but all the suggestions I found looked as complex as using SQL Client objects.
Thanks so much!
|All times are GMT -4. The time now is 03:06 PM.|
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.