using System.Collections.Generic; using System.Linq; using BS.Shared; namespace BeWo.Data.Entities { public static class BeWoEntityExtensions { public static List FindByType(this IList pList, ValueListEntryType pType) { return pList.Where(item => item.Entry.Type == pType).ToList(); } public static List FindByTypes(this IList pList, List pTypes) { return pList.Where(item => { foreach (var valueListEntryType in pTypes) { if (item.Entry.Type == valueListEntryType) return true; } return false; } ).ToList(); } public static ValueListEntry2Object FindSingleByType(this IList pList, ValueListEntryType pType) { List lMatches = pList.FindByType(pType); if (lMatches.Count == 1) { return lMatches[0]; } return null; } } }