none
LINQ not returning results RRS feed

  • Question

  • I have tables that I am trying to get info into a "var".  The parent table is StatementRec and the child table is StatementDetail.  Both have secondary keys called FK_SatementDateID.  Here is my code:

     var Id = ((WPF_Statements_Process.StatementDate)(comboBox1.SelectedValue)).PK_StatementDateID;

    var data = from sr in db.GetTable<StatementRec>()
                           from sd in db.GetTable<StatementDetail>()
                           where sr.FK_StatementDateID  == Id && sd.FK_StatementDateID  == Id
                           select new {sr, sd };

     

    There is data in the tables, but it is returning empty.  Do I have my LINQ formatted incorrectly?  I plan to take these results and attach them to a WPF grid.  Thanks for the assist.  .nic..

     

    Friday, September 17, 2010 3:40 PM

Answers

  • I don't use WPF a lot so I don't know much about it, however in a DGV in order to show columns either make a property called AutoGenerateColumns=true or manually add columns to control before binding something to it.

    Could you put the result of the query in a collection and see if the collection has elements ex: ToList();

    Friday, September 17, 2010 5:00 PM

All replies

  • Hmm, how do you know is empty? This queries won't be executed until there is actually a need for them to be executed, bind them to a control or do other operation that will force the execution of this queries and then check if they are still null.

    Regards

    Friday, September 17, 2010 4:00 PM
  • HI Serguey,

    Thanks for replying back.   I added the following and it doesn't seem to show anything

     

      xamDataGrid1.DataSource = data;

     

    Friday, September 17, 2010 4:31 PM
  • I don't use WPF a lot so I don't know much about it, however in a DGV in order to show columns either make a property called AutoGenerateColumns=true or manually add columns to control before binding something to it.

    Could you put the result of the query in a collection and see if the collection has elements ex: ToList();

    Friday, September 17, 2010 5:00 PM
  • Hi nickpatel,

    How about your problem ? Have you figured it out ? What's the results if you follow Serguey's suggestion ?

    Best regards,
    Alex Liang
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, October 6, 2010 7:55 AM
    Moderator