Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
181 Points
435 Posts
Apr 28, 2012 09:41 PM|LINK
HI,
I'm building a MVC3 app. Can I use "ToArray()" to make a db selection result into an array? Here is an example:
for (int i = 0; i < 5; i++) { var rows = from c in db.Table1 where ... select c.ColumnValue; string[] newArray = new string[4];
newArray = rows.ToArray();
}
Question: Is this correct? If not, how do I acheive what I want? I want to put the values in rows into an array.
Or, Option2:
int i = 0; foreach (var item in XYZ) { newArray[i] = item; i++; }
Is this correct?
Note: for both implementations above, I can compile the app, but when I run it, I get this error:
The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities.
Thanks!!
Claudia
claudia888
Member
181 Points
435 Posts
How to put a db selection result into an array?
Apr 28, 2012 09:41 PM|LINK
HI,
I'm building a MVC3 app. Can I use "ToArray()" to make a db selection result into an array? Here is an example:
for (int i = 0; i < 5; i++)
{
var rows = from c in db.Table1
where ...
select c.ColumnValue;
string[] newArray = new string[4];
newArray = rows.ToArray();
}
Question: Is this correct? If not, how do I acheive what I want? I want to put the values in rows into an array.
Or, Option2:
int i = 0;
foreach (var item in XYZ)
{
newArray[i] = item;
i++;
}
Is this correct?
Note: for both implementations above, I can compile the app, but when I run it, I get this error:
The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities.
Thanks!!
Claudia