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 06:35 PM.|
Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.