Link to home
Start Free TrialLog in
Avatar of bmanmike39
bmanmike39

asked on

How do I separate the values in my query or .ToList() into variables I can access in Entity?

Below I can show the record in a gridView but how do i parse the record field and move them to variables for manipulation?  When i try to put them in a label i get a string of long string of characters but not the value.

string F = "Female";
string L = "licensed";
var HR = OE.tbl_Dept.Where(d => d.Gender.Equals(F) && d.Licensed.Equals(L) );

DeptGrid.DataSource = HR.ToList();
DeptGrid.DataBind();

Open in new window

Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Where are you trying to access the fields from, DataGrid or the original results from HR. It would also help to see the code you are using.
Avatar of bmanmike39
bmanmike39

ASKER

Preferably from the original HR
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you!  But I'm still have the problem manipulating each piece of data in the record individually.  the string builder allows me to display it all in a label, but i want to separate it into multiple variables.
In the foreach loop the d is a row from the database table, in this case a row from the tbl_Dept,  with all it columns contain in it. To access any of the properties with in d just enter d.ColumnName and assign it to some variable of the same type as that of the column. For example lets say that the table has a column name DeptNumber and in the database table it is an int then to assign that to a variable in your code called deptNum you would the following.

int deptNum = d.DeptNumber;

If you are still having issues please post the code and any exceptions messages and I will have a look at it.
Excellent!  Thanks,  you have help me with my understanding of how this works greatly!
Not a problem bmanmike39, glad to be of help.