> > public void ButtonSearch_Click(object sender, RoutedEventArgs e) > { > DataClasses1DataContext db = new DataClasses1DataContext(); > > var CustomerFilter='%'+txtCustomerFilter.Text+'%'; > > 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 }; > > lv2.ItemsSource = customers; >> } >You need to get away from var because it won't pass between classes.
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) ;