I have two large lists of object. First (about of 1 000 000 objects):
public class BaseItem
{
public BaseItem()
{
}
public double Fee { get; set; } = 0;
public string Market { get; set; } = string.Empty;
public string Traider { get; set; } = string.Empty;
public DateTime DateUtc { get; set; } = new DateTime();
}
Second (about of 20 000 objects):
public class TraiderItem
{
public TraiderItem()
{
}
public DateTime DateUtc { get; set; } = new DateTime();
public string Market { get; set; } = string.Empty;
public string Type { get; set; } = string.Empty;
public double Price { get; set; } = 0;
public double Amount { get; set; } = 0;
public double Total { get; set; } = 0;
public double Fee { get; set; } = 0;
public string FeeCoin { get; set; } = string.Empty;
}
I need to find all Traider items in Base items when DateUtc are equals and Fee are equals. Now i am using Any method:
traiderItemsInBase = traiderItems.Where(a => baseItems.Any(x => x.DateUtc == a.DateUtc && Math.Round(x.Fee, 8) == Math.Round((double)a.Fee * 0.4, 8))).ToList();
But this way is very-very slow. Is there a way to make this more efficient?Is there possibility to use HashSet in this case?