Iterating through entity object in entity framework

c# datatable entity-framework

Question

I just started using Entity Framework a week ago, and I've been searching online for what I believe to be a straightforward solution for the past day.

The question is, "Is there a way to iterate through data (columns) in an entity object?" "I have extracted data from a table, but before I tie it to a repeater I want to apply some modifications to data, such merge data from 2 columns.

I tried hard to find a solution but was unsuccessful, thus I had to use reflection to turn my entity object into a datatable and perform operations using "datatable.rows[row no][col no]"... however I think this is an extremely foolish way to do things. I mean, what good is using an ORM if you have to use datatables, thus is there a method to iterate like datatables in EF-object? Like:

dbtest1entities db = new  dbtest1entities();//"dbtest1entities " is like database
var info = db.mp_data;//"mp_data" is the table i want to fetch data from.

Can I cycle through the data in var info column-wise and row-wise?

Please assist with this matter. (NO LONGER ABLE TO USE GOOGLE!)

1
0
12/9/2013 11:50:59 AM

Accepted Answer

BD.Entities model = new BD.Entities();

var gg = model.ALUNOS;

foreach (var i in gg)
{
   string teste = i.NOME;
}
6
12/9/2013 12:07:07 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow