maybe foolish question, first times with linq to entities (well, linq in general).
table with id(int), value(decimal), name(string)
for each record i need
id list<string> id value name
THE FOLLOWING WORKS FINE
int pageSize=10
int pageIndex=2
var data = (from c in db.Customers
orderby c.ID
select new { c.ID, c.Value, c.Name }
).Skip(pageSize * pageIndex).Take(pageSize).ToArray();
but doesn'organize the data in the way i need them. However the results are like:
1 100 name A
2 300 name B
3 200 name C
4 100 name D
THE FOLLOWING MAKE ME MAD
int pageSize=10
int pageIndex=2
var data2 = (from c in db.Customers
orderby c.ID
select new
{
id = c.ID,
cell = new List<string> {
SqlFunctions.StringConvert((double)c.ID),
SqlFunctions.StringConvert(c.Value),
c.Name
}
}
).Skip(pageSize * pageIndex).Take(pageSize).ToArray();
which brings
1
1 100 name A
2
name B 300 2
3
3 200 name C
4
name D 100 4
and so on...
i can't understand why, and how to solve it without writing lenghty code i would skip with love.
Help please, Fabrizio