本文整理汇总了C#中Entities.List.Distinct方法的典型用法代码示例。如果您正苦于以下问题:C# List.Distinct方法的具体用法?C# List.Distinct怎么用?C# List.Distinct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entities.List
的用法示例。
在下文中一共展示了List.Distinct方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUserRoles
public List<Role> GetUserRoles(string username)
{
var result = new List<Role>();
var existingUser = this.userRepository.GetSingleByUsername(username);
if (existingUser != null)
{
result = this.GetUserRoles(existingUser);
}
return result.Distinct().ToList();
}
示例2: ProcessImagesForXmlList
/// <summary>
/// Process all the images for the given list of images
/// retrieved from the sites HTML - this processes all images
/// in a given list of xml nodes for the sitemap.
/// </summary>
/// <param name="xmlNodeList"></param>
/// <param name="siteMapUrl"></param>
/// <param name="squishedCssImages"></param>
/// <returns></returns>
public IEnumerable<string> ProcessImagesForXmlList(XmlNodeList xmlNodeList, string siteMapUrl, ref List<SquishedImage> squishedCssImages)
{
List<SquishedImage> images = new List<SquishedImage>();
List<string> imageList = new List<string>();
List<string> alreadyProcessed = new List<string>();
foreach (XmlNode node in xmlNodeList)
{
string imageUrl = node.InnerText;
if (!_commonUtils.IsValidFileExtension(imageUrl))
{
break;
}
WebClient client = new WebClient();
string downloadString = client.DownloadString(imageUrl);
imageList.AddRange(_commonUtils.GetImagesInHtmlString(downloadString));
// Process images in CSS file.
squishedCssImages.AddRange(ProcessCss(downloadString, imageUrl, ref alreadyProcessed));
}
return imageList.Distinct();
}
示例3: RetrieveAllEntities
private IEnumerable<Entity> RetrieveAllEntities(DTProject project)
{
List<Entity> projectEntities = new List<Entity>();
projectEntities.Add(project);
var subEntities = GetSubEntities(project, projectEntities);
if (subEntities.Count() > 0)
projectEntities.AddRange(subEntities);
return projectEntities.Distinct();
}