none
Dynamic Linq to Object RRS feed

  • Question

  • Hi all. I am stuck.

    I have an object called tblTask which has fields such as T3_1, T3_2, T3_3, T3_4

    I want to run a dynamic query to find out if any information is in that field or not.

    The idea is that there are 10 questions and I need to know which ones have been completed. i.e. 6/10 complete.

    I have tables called tblTask1, tblTask2, tblTask3 etc.

    I want to run a query such as

    Dim res = FROM x IN tblTask{Dynamic Number}
    WHERE T{Dynamic Number}_{Dynamic Number} IS NOT NULL
    
    If res.Count > 0 THEN
    myCount += 1
    END IF
    

    Any ideas?

    Thanks in advance. Scott

    BTW I have already done it BUT this way contacts the database each time. I want it to only query the object in memory

    For t = 1 To totTaskInRecord.Count
      Dim sql As String
      sql = String.Format("Select T{0}_UniqueID FROM tblTask{0} WHERE T{0}_{1} IS NOT NULL AND T{0}_ItemNo = {2}", iTaskNo, t, rec.T3_ItemNo)
      Dim ret = dbx.ExecuteStoreQuery(Of Integer)(sql)
      If ret.Count > 0 Then
      iTotalComplete += 1
      End If
     Next
    


    Friday, April 15, 2011 1:49 PM

Answers

All replies