locdang
asked on
Help with LINQ to sql
Hi everyone,
I need some help with being able to use LINQ to fill a List<> of my own object type.
the error i am receiving is "Cannot implicitly convert type 'System.Linq.IQueryable<LI NQExperime nt.tblSome thing>' to 'System.Collections.Generi c.List<LIN QExperimen t.Somethin g>'. An explicit conversion exists (are you missing a cast?)"
here is my example below, hopefully it will show what i wish to achieve
Thanks,
Xavier.
I need some help with being able to use LINQ to fill a List<> of my own object type.
the error i am receiving is "Cannot implicitly convert type 'System.Linq.IQueryable<LI
here is my example below, hopefully it will show what i wish to achieve
Thanks,
Xavier.
private void button1_Click(object sender, EventArgs e)
{
DemoDBDataContext demoDB = new DemoDBDataContext ();
var res = from p in demoDB.Somethings where p.Foo == "abc" select p;
List<Something> somethingCollection = res;
}
class Something
{
public String Foo
{
get;
set;
}
public Int32 Bar
{
get;
set;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect! Exactly what i needed!
ASKER
Thank you very much!
Not a problem, glad I was able to help. ;=)
ASKER
Open in new window