I have a string array named batches that contains batchnames. I want to compare it with Batch entity and get all the records that matches with batchName field of entity. I am using Entity Framework 6.
class Batch
{
int batchId { get; set;}
string batchname { get; set;}
string info { get; set;}
DateTime date { get; set;}
}
Right now I am doing it like this using foreach
foreach(var item in batches)
{
var res=opt.Batch.Where(i=>i.batchname==item).FirstOrDefault();
batchlist.Add(res);
}
How can I do it with LINQ without using foreach