troubleshooting Question

LINQ and Parameter passing VB.NET...

Avatar of si2030
si2030 asked on
.NET ProgrammingVisual Basic.NET
6 Comments1 Solution3406 ViewsLast Modified:
Hi there,

I am working on a project where I am obtaining results from a LINQ query and then passing that query through to a sub in another object. In that sub I then do another LINQ query to separate the original query into 5 areas.. assets, liabilities, equity, revenue and expenses.

The error I am getting is:

"Late binding operations cannot be converted to an expression tree."



The code is below: The first part is the original LINQ query and calling of the sub its to be used in.



The receiving object's sub's interface that passes this query is as follows:

Public Sub displayAccountsInDGV(ByVal accountsFound As IQueryable)



MY QUESTION
How do I TYPE a linq query to pass it from one objects sub to another and be able to use it in another LINQ query here??

Kind Regards

Simon


'LINQ query
                    Dim selectedAccounts = From account In db.accounts _
                                                  Order By account.acc_id _
                                                  Where ((isActive = True And hasActivity = True And account.inactive = False) Or _
                                                  (isActive = True And hasActivity = False And account.activity = False And account.inactive = False) Or _
                                                  (isActive = False And hasActivity = True And account.activity = True And account.inactive = True)) _
                                                   Select account.acc_id, _
                                                          account.acc_type, _
                                                          account.acc_name, _
                                                          account.is_bank_acc, _
                                                          account.inactive, _
                                                          account.activity
                    
                    'call the sub - issue is with the parameter.....
                    View.displayAccountsInDGV(selectedAccounts)
 
 
 
 
Public Sub displayAccountsInDGV(ByVal accountsFound As IQueryable)
 
'USING THE PASSED QUERY RESULT IN THE SUB... gives me late binding error..
'Here is where I get the error.......
        assets = From accounts In accountsFound _
                 Where accounts.acc_type = "A" _
                 Order By accounts.print_pos
 
        liabilities = From accounts In accountsFound _
                          Where accounts.acc_type = "L" _
                          Order By accounts.print_pos
 
        equities = From accounts In accountsFound _
                     Where accounts.acc_type = "O" _
                     Order By accounts.print_pos
 
        revenues = From accounts In accountsFound _
                      Where accounts.acc_type = "R" _
                      Order By accounts.print_pos
 
        expenses = From accounts In accountsFound _
                       Where accounts.acc_type = "E" _
                       Order By accounts.print_pos
.
.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros