DUDE!!!! You are so smart with this stuff.
I'm not even kidding.... I just posted a boo-hoo about an error I was getting on casting the object type, and you had already replied with a prediction about how using "var" was going to cause the exact problem that I ran into.
You were right on it!
I had to revise my Linq call just like you said:
IEnumerable<customer_source> customers = from a in db.customers
where SqlMethods.Like(a.custno, CustomerFilter) || SqlMethods.Like(a.company, CustomerFilter)
orderby a.custno
select a;
not this "loosey-goosey, hey C# 3 has anonymous types that will get you in trouble" way:
var customers = from a in db.customers
where SqlMethods.Like(a.custno, CustomerFilter) || SqlMethods.Like(a.company, CustomerFilter)
orderby a.custno
select new { a.custno, a.company, a.phone, a.faxno };
>You need to get away from var because it won't pass between classes.
>
>Either pass the whole record:
>
>
> IEnumerable<customer> customers = from a in db.customers
> where SqlMethods.Like(a.custno,CustomerFilter) || SqlMethods.Like(a.company,CustomerFilter)
> orderby a.custno
> select a;
>
>
>Or create a new class:
>
>
> public class dataitem
> {
> public int custno { get; set; }
> public string company { get; set; }
> public string phone { get; set; }
> public string faxno { get; set; }
>
> public dataitem(int cno, string c, string p, string f)
> {
> custno = cno;
> company = c;
> phone = p;
> faxno = f;
> }
> }
>
>
>And return it:
>
>
> IEnumerable<dataitem> customers = from a in db.customers
> where SqlMethods.Like(a.custno,CustomerFilter) || SqlMethods.Like(a.company,CustomerFilter)
> orderby a.custno
> select new dataitem(a.custno, a.company, a.phone, a.faxno) ;
>