我想通过1个db调用找到列表和db表之间的重复值。该列表包含1000+行,而db表包含100k +行。可能吗?
列表结构:
public class Invitations
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required(ErrorMessage = "Interview ID is required")]
public int InterviewId { get; set; }
[Required(ErrorMessage = "Candidate Name is Required")]
public string CandidateName { get; set; }
[Required(ErrorMessage = "Candidate Email is Required")]
public string CandidateEmail { get; set; }
[StringLength(450)]
[Index(IsUnique = true)]
public string Guid { get; set; }
}
和数据库结构:
BatchInvitationDto batchInvites = new BatchInvitationDto();
batchInvites.Candidate // contains 1000+ rows
现在列表中有1000多行
context.Invitations
,并且数据库表pip install --upgrade Flask
中有100k +行。我可以通过一次呼叫检查重复的电子邮件(在db和list变量中都存在的电子邮件)吗?或最好的方法是什么?
答案 0 :(得分:1)
有关电子邮件的重复:
var lst = batchInvites.Candidate.Select(y => y.Email);
db.Invitations
.Where(x => lst.Contains(x.Email))
.ToList();