brgdotnet
asked on
How to get an item from a "var" variable when returned as sql string
I need the help from someone who has a really good idea of how to help me on this problem.
I am working with C#. I am calling a service that returns what looks like rows in a table. I need to know how to get only one value from what is returned.
Below is my C# code and I show the debugger contents the ClientClub var variable.
50 var clientClub = ClientService.GetClubs(); // This is the C# code on line 50
51 bool madeItHere=true; // line 51
When I trace through the debugger and get to line 51 above, then I can do a quick watch or hover over the variable "clientClub". When I do, the following information about the contents of "clientClub" are shown :
{SELECT [t0].[ClubID] AS [ClubId], [t0].[ClubCode] AS [Code], [t0].[ClubName] AS [Name], [t0].[ClubDescription] AS [Description], [t0].[SortOrder]
FROM [dbo].[Club] AS [t0]
ORDER BY [t0].[SortOrder]
So here is my question. I need to get the String value "ClubName" which is stored in my var variable "clientClub". How can I do this? Please help.
I am working with C#. I am calling a service that returns what looks like rows in a table. I need to know how to get only one value from what is returned.
Below is my C# code and I show the debugger contents the ClientClub var variable.
50 var clientClub = ClientService.GetClubs(); // This is the C# code on line 50
51 bool madeItHere=true; // line 51
When I trace through the debugger and get to line 51 above, then I can do a quick watch or hover over the variable "clientClub". When I do, the following information about the contents of "clientClub" are shown :
{SELECT [t0].[ClubID] AS [ClubId], [t0].[ClubCode] AS [Code], [t0].[ClubName] AS [Name], [t0].[ClubDescription] AS [Description], [t0].[SortOrder]
FROM [dbo].[Club] AS [t0]
ORDER BY [t0].[SortOrder]
So here is my question. I need to get the String value "ClubName" which is stored in my var variable "clientClub". How can I do this? Please help.
50 var clientClub = ClientService.GetClubs(); // This is the C# code on line 50
51 bool madeItHere=true; // line 51
--------------------------Next Line Shows Contents of clientClub in debugger-----------
{SELECT [t0].[ClubID] AS [ClubId], [t0].[ClubCode] AS [Code], [t0].[ClubName] AS [Name], [t0].[ClubDescription] AS [Description], [t0].[SortOrder]
FROM [dbo].[Club] AS [t0]
ORDER BY [t0].[SortOrder]
ASKER
Ok, I can see that. So how do I get the data field I asked about? I am under much pressure to get this done.
Still not answered my question ! Do you know what type the service returns ?
Depending of the type that's returned, you can try the following: clientClub["Name"].ToStrin g()
ASKER
I deeply appreciate your help Dhaest. I tried accessing the value as you suggested but I get the following error: Error 1 The name 'Name' does not exist in the current context.
I don't know what type the service returns, but I found this. Is this correct:
(new System.Linq.SystemCore_Enu merableDeb ugView<Cli ent.Core.M odel.Ethni city>(clie ntClub)).I tems[0].De scription
I don't know what type the service returns, but I found this. Is this correct:
(new System.Linq.SystemCore_Enu
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This guy Dhaest is one sharp cookie!!!
Is it a datarow, datatable, delimited text, ...