I'm trying to test out a dynamic join extension method as defined here to join two datasets(dataset1 and dataset2) on multiple conditions. My join condition is as shown below
outerSelector = "new ( dataset1.ToBeReconciled as col1, dataset1.TransactionDate as col2)";
innerSelector = "new ( dataset2.ToBeReconciled as col1, dataset2.TransactionDate as col2)";
This does not result in any error, but at the same time always returns zero records, even though I have records that match this condition.
Any idea how to make this work? Thanks!
Perhaps you should start with a simple example, and then try to work through what you have there... I've composed a simple to understand one below..
void Main()
{
var fruits = new List<Fruit>
{
new Fruit{ GroceryId = 1,Name = "Apple", ProductId = 1},
new Fruit{ GroceryId = 1,Name = "Orange", ProductId = 2},
};
var groceries = new List<Grocery>
{
new Grocery { GroceryId = 1, Name = "Fruits and Vegetables" },
new Grocery { GroceryId = 2, Name = "Drinks and snacks" },
};
var joinedResults = fruits.Join(groceries, // References the groceries declared above,
fruit => fruit.GroceryId, // Join by GroceryId located on the Fruit
grocery => grocery.GroceryId, // Join by the GroceryID located on Grocery
(product, grocery) => new
{
ProductId = product.ProductId,
ProductName = product.Name,
GroceryName = grocery.Name
});
}
public class Fruit
{
public int ProductId { get; set; }
public int GroceryId { get; set; }
public string Name { get; set; }
}
public class Grocery
{
public int GroceryId { get; set; }
public string Name { get; set; }
}