troubleshooting Question

Build dynamic LINQ Query over Datatables

Avatar of sudgupta
sudgupta asked on
.NET ProgrammingVisual Basic.NET
14 Comments1 Solution5046 ViewsLast Modified:
Below is LINQ query which returns the New records which exist in dtFreshdata  but not in dtSnapShot.
My question is that
how to generalize this code so that it works for all DataTables of different schema
In this query I hard coded column name but I want to construct it dynamically.
and I have more than one Constraint column and i want Group join ON more than one constraints.

for e.g string[] strArrConstraints contains the constraints.

I hope You people come out with a solution ASAP.
Dim objquery = From FreshData In dtFreshData.AsEnumerable() _
                           Group Join SnapShotData In dtSnapShot.AsEnumerable() _
                 On FreshData("ACCTID") Equals SnapShotData("ACCTID") Into HaveMatch = Any() _
            Where Not HaveMatch _
            Select ACCTID = FreshData("ACCTID"), ACCTNAME = FreshData("ACCTNAME"), ACCTADDRESS = FreshData("ACCTADDRESS")
ASKER CERTIFIED SOLUTION
naspinski

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
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 14 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