none
query multiple items form IList RRS feed

  • Question

  • I have a function that I am making a call against my IList in order to return back my query to bind to my Gridview.  Kind of stuck at this point not knowing how to query the Ilist "items" and not just a single "item" 

     public void geteverythingforGRID()
            { 

                List<SearchClass> siList = new List<SearchClass>(); 
            DataTable dtSomeOtherDTQuery = BuildEverythingGRIDTable(buildSaleRepQuery(), buildPMQuery());

                DataRow[] drsO = dtSomeOtherDTQuery .Select("REP <> '"+ String.Empty +"' PM <> '"+ String.Empty + "'" ) ;

                    foreach(DataRow dr in drsO)

                    {

                    var s = from sr in siList 
                            from spm in sr.PM

                            where sr.REP == dr["REP"].ToString()

                            select sr;

                        foreach (SearchClass sr in s)
                        {
                        
                        sr.OtherValue = dr["OtherValue"].ToString(); 
                        
                        }
    Thursday, March 18, 2010 9:39 PM

All replies

  • Hello,

     

    Welcome to LINQ to SQL forum!

     

    Are you using LINQ to SQL query?   From your sample codes, it is more like LINQ to Objects or LINQ to DataSet.   Could you please make your scenario clearer?   I will do my best to help!

     

    Have a nice weekend!

     

     

    Best Regards,
    Lingzhi Sun

    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.
    Friday, March 19, 2010 5:43 AM
    Moderator
  • I am new to using Linq so I may be mistaken as to what type I am using.  I think its more in line to using Linq to objects since my Ilist selected items are stored in properties.  I have several list boxes from a search page which permits several selections from each list box.  I then put those into properties which are then stored in my IList.  Now that I have all my items from the Ilist I now need to run one last query to bind them to the datagrid hence the above code.  I can't seem to figure out how to get each of the items form the IList and then put them into a query.  

     

    Thanks!!

    Friday, March 19, 2010 12:56 PM
  • Hello,

     

    Thanks for following up!   So the siList stores a set of SearchClass and each SearchClass contains some selected value as properties, right?   Then how do you want to make the LINQ query?   What should be the result?   How do you want to combine the LINQ query and the DataTable rows?  Could you please also provide some sample codes of the SearchClass?  

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    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.
    Saturday, March 20, 2010 6:44 AM
    Moderator
  • Hello,

     

    I am writing to check the status of the issue on your side.  Would you mind letting me know how is the problem now? 

     

    If you need further assistance, please feel free to let me know.   I will be more than happy to be of assistance.

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    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, March 24, 2010 1:13 AM
    Moderator