In a method I am trying to develop, I have two DataTables named slotCounts and createdSlots. The table createdSlots has a column TIMESLOT which is typeof(DateTime), and slotCounts has a column SCHDTIME which is typeof(DateTime), from which these tables can be related.
I want create a new DataTable consisting of rows from createdSlots except where there is a matching row in slotCounts. Conversely, I could just delete those rows from createdSlots that have a matching row in slotCounts.
I have been able to filter DataTables in some other methods, but not filtering one DataTable against another. Is this possible?
I want create a new DataTable consisting of rows from createdSlots except where there is a matching row in slotCounts. Conversely, I could just delete those rows from createdSlots that have a matching row in slotCounts.
I have been able to filter DataTables in some other methods, but not filtering one DataTable against another. Is this possible?
Manikavelu VelayuthamPosted Sep 14, 2010, 8:06 AM
There you can easily do a Join between the two tables like you do in SQL SERVER tables.
Below syntax will help you. here i have shown you the example using Customers & Orders Table. Same thing you can apply it in your scenario
LINQ Example
var custOrders =
customers.
Join(orders, c => c.CustomerID, o => o.CustomerID,
(c, o) => new { c.Name, o.OrderDate, o.Total }
);
Lambda Expression
var custOrders =
from c in customers
join o in orders on c.CustomerID equals o.CustomerID
select new { c.Name, o.OrderDate, o.Total };
Manikavelu VelayuthamPosted Sep 14, 2010, 8:27 AM
Todd BurrellPosted Sep 14, 2010, 8:19 AM