0

I have written a WPF program with c# that uses a SQL server database here are my tables

the sell tables

the clients table

the bank table

the goal when the user checks the radiobutton, a listview named lv_factors shows the sell factors that are sold by check. here is the code:

private void rb_sell_Checked(object sender, RoutedEventArgs e)
    {
        var db = new mydataDataContext();
        var all = from p in db.tb_sellFacts
                  from r in db.tb_Clients
                  from s in db.tb_sellChecks
                  from t in db.tb_banks
                  from q in db.tb_checkStatus
                  where p.id_sellFact == s.id_sellfact && 
                        r.id == p.id_customer && 
                        t.id == s.id_bank && 
                        q.id == s.passed
                  select new dataTypes.AllChecks
                  {
                      bankname = t.name.ToString(),
                      id = p.id_sellFact.ToString(),
                      buydate = p.buydate,
                      checkaccount = s.checkaccount,
                      checkfee = s.paidprice.ToString(),
                      checknumber = s.checknumber,
                      checkstate = q.status,
                      custId = p.id_customer.ToString(),
                      idbank = s.id_bank.ToString(),
                      insertdate = p.insertdate,
                      passed = q.id.ToString(),
                      checkDate = s.checkdate,
                      CustName = r.family
                  };
        lv_factors.ItemsSource = all;

    }

but the listview doesn't show anything.can anyone help me?

Magnus
  • 45,362
  • 8
  • 80
  • 118
Hooman
  • 192
  • 3
  • 12
  • 1
    Have you tired `all.ToList()`? – Aducci Apr 24 '14 at 13:08
  • yes it doesn't work.i have written another code for another table ,buyfactors exactly the same columns and the same code like above and it works perfect but this one doesn't – Hooman Apr 24 '14 at 13:25
  • Are you getting any values in variable all ? have you tried to use joins ? – Karthik Ganesan Apr 24 '14 at 16:27
  • yeah it gives some values but they dont display in listview. i checked the bindings for the columns in listview and they were correct. – Hooman Apr 25 '14 at 11:20

1 Answers1

0

didnt get you exception by this query ? you must get exception, .ToString() can not be called in linq queries, it cant be converted to expression tree. i posted ( here ) an answer says what can be called on linq queries.

Community
  • 1
  • 1
Amir Sherafatian
  • 2,083
  • 2
  • 20
  • 32
  • No i dont get any exception at all. like i said above i have written another code excatly the same above for another table buywithcheck with exactly the same columns and same data type and it works fine – Hooman Apr 25 '14 at 11:17