将IEnumerable列表排序为仅一个具有相同地址的实例 [英] Sort IEnumerable list to only one instance of same adress
本文介绍了将IEnumerable列表排序为仅一个具有相同地址的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
IEnumerable<Email> emails;
try
{
emails = (from p in DatabaseConnection.Emails where p.Newsmail == true select p);
}
catch (Exception x)
{
throw x;
}
关于如何对Enum列表进行排序的任何建议,以使列表中的每个电子邮件地址都只有一个?数据库表可以具有2个具有相同电子邮件地址的实例,因此,为了避免垃圾邮件,我只需要在邮件列表中保留一个实例...
有什么建议吗?
最好的问候
Any suggestions how to sort the Enum list, to have ONLY one of each email adress in the list? The database table can have 2 instances of same email adress, so to keep spam away, I need to only have ONE of the instances in the mailing list...
Any suggestions?
Best regards
推荐答案
尝试以下操作:
Try this:
emails = (from p in DatabaseConnection.Emails where p.Newsmail == true select p).Distinct();
请参见此处 [ ^ ].
这篇关于将IEnumerable列表排序为仅一个具有相同地址的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文