Is is my method that runs the query:
Public Overrides Sub Start()
IsRunning = True
LastStart = Now
Dim Pred As New PredicateExpression
Dim Rel As New RelationCollection
With Rel
.Add(TblLeadEntity.Relations.TblLeadCategoryEntityUsingLeadID, JoinHint.Inner)
.Add(TblLeadCategoryEntity.Relations.TblCategoryEntityUsingCategoryID, JoinHint.Inner)
.Add(TblCategoryEntity.Relations.TblCategoryLetterEntityUsingCategoryID, JoinHint.Inner)
.Add(TblCategoryLetterEntity.Relations.TblLetterEntityUsingLetterID, JoinHint.Inner)
End With
' Rel.Add(TblLetterEntity.Relations.TblLetterQueueEntityUsingLetterID, JoinHint.Left)
' Rel.Add(TblLetterEntity.Relations.TblLeadLetterEntityUsingLetterID, "tblLeadLetter", JoinHint.Left)
Dim CustomFilter As IPredicateExpression = New PredicateExpression
Dim Expr As IExpression = New Expression(EntityFieldFactory.Create(TblLeadFieldIndex.LeadID))
CustomFilter.Add(PredicateFactory.CompareExpression(TblLeadLetterFieldIndex.LeadID, ComparisonOperator.Equal, Expr))
Rel.Add(TblLetterEntity.Relations.TblLeadLetterEntityUsingLetterID, "tblLeadLetter", JoinHint.Left).CustomFilter = CustomFilter
Dim CustomFilter2 As IPredicateExpression = New PredicateExpression
Dim Expr2 As IExpression = New Expression(EntityFieldFactory.Create(TblLeadFieldIndex.LeadID))
CustomFilter2.Add(PredicateFactory.CompareExpression(TblLetterQueueFieldIndex.LeadID, ComparisonOperator.Equal, Expr2))
Rel.Add(TblLetterEntity.Relations.TblLetterQueueEntityUsingLetterID, "tblLetterQueue", JoinHint.Left).CustomFilter = CustomFilter2
Pred.Add(PredicateFactory.CompareValue(TblLeadFieldIndex.LeadActive, ComparisonOperator.Equal, -1))
Pred.AddWithAnd(PredicateFactory.CompareNull(TblLetterQueueFieldIndex.LetterQueueID))
Pred.AddWithAnd(PredicateFactory.CompareNull(TblLeadLetterFieldIndex.LeadLetterID))
Dim Fields As New ResultsetFields(4)
Fields.DefineField(TblCategoryLetterFieldIndex.LetterID, 0, "LetterID")
Fields.DefineField(TblLeadFieldIndex.LeadID, 1, "LeadID")
Fields.DefineField(TblLeadCategoryFieldIndex.AddDate, 2, "AddDate")
Fields.DefineField(TblCategoryLetterFieldIndex.LetterWait, 3, "LetterWait")
Dim Dao As New DaoClasses.TypedListDAO
Dim dt As New DataTable
Dao.GetMultiAsDataTable(Fields, dt, 0, Nothing, Pred, Rel, False, Nothing, Nothing, 0, 0)
IsRunning = False
LastEnd = Now
End Sub
It builds the relations and predicates for the TypeListDAO and then executes the query. There is no transactional context or sort order.
I couldn't find anything that might cause problems in the code above, but would be grateful for a review just in case. The Dao.GetMultiAsDataTable line of code is where it hangs, more specifically, it is the Line "Return MyBase.ExecuteMultiRowDataTableRetrievalQuery..." from the TypedListDAO generic class. I am using self-servicing. Thanks again.