Arawn
Arawn

Reputation: 27

Iterating through entity object in entity framework

I'am pretty new to Entity Framework(started about a week ago) and I've been looking around for solution to what I think is a simple problem for a day now,

"I have extracted data from table but before I bind it to repeater I want to do some enhancements to data like combine data from 2 columns and as such , so what I'm asking is, is there a way to iterate through data(columns) in an entity object?"

I tried a lot but couldn't find an answer so I had to use reflection to convert my entity object into datatable and do manipulations using "datatable.rows[row_no][col_no]" ... but I find this way really stupid ..I mean what's the point of using an ORM if you have to use datatables...so is there a way of iterating 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.

Question: Can I iterate through data in var info row and column-wise.

Kindly help in this regard.(CANT GOOGLE ANYMORE!!!!!!)

Upvotes: 0

Views: 11498

Answers (1)

Jhonatas Kleinkauff
Jhonatas Kleinkauff

Reputation: 966

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

var gg = model.ALUNOS;

foreach (var i in gg)
{
   string teste = i.NOME;
}

Upvotes: 6

Related Questions