Let's say I have a List of Detail class with 1000 entries. How can I exactly retrieve the matching data from the database Details table using LINQ method with a combination of both FirstCode and SecondCode properties?
public class Detail
{
public string FirstCode { get; set; }
public string SecondCode { get; set; }
}
If we're going to retrieve a single data it would be like this:
foreach(var detail in details)
{
var retrievedData = context.Details
.Where(x => x.FirstCode == detail.FirstCode && x.SecondCode == detail.SecondCode)
.FirstOrDefault();
// Add to some list here
}
But I don't want to fetch 1000 times from the database, also I don't want to get all data from Details table and then do the searching within the .NET level, because it's not ideal if we have bunch of data(for ex. 500,000+ records in Details table).