Link to home
Start Free TrialLog in
Avatar of Ameerh24
Ameerh24

asked on

why I got 'AnonymousType#1' error in LINQ ?

hi,
I got AnonymousType#1 error when I am trying this code below:

I got error in foreach statement, The error is:
Error      1      Cannot convert type 'AnonymousType#1' to 'MyTable'


var future_gen = from p in clsDB.MyTables
                         where p.Active == 1
                         select new 
                         {
                             p.ID,
                             p.Image_Path,
                         };
        
        string id;
        foreach (MyTable fg in future_gen)
            id = fg.ID.ToString();

Open in new window

Avatar of Ameerh24
Ameerh24

ASKER

or is there anyway so I can get each ID from this future_gen variable and save it in a string ?
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
SOLUTION
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
The solution was great