41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
using BS.Shared;
|
|
|
|
namespace BeWo.Data.Entities
|
|
{
|
|
public static class BeWoEntityExtensions
|
|
{
|
|
public static List<ValueListEntry2Object> FindByType(this IList<ValueListEntry2Object> pList, ValueListEntryType pType)
|
|
{
|
|
return pList.Where(item => item.Entry.Type == pType).ToList();
|
|
}
|
|
|
|
public static List<ValueListEntry2Object> FindByTypes(this IList<ValueListEntry2Object> pList, List<ValueListEntryType> 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<ValueListEntry2Object> pList, ValueListEntryType pType)
|
|
{
|
|
List<ValueListEntry2Object> lMatches = pList.FindByType(pType);
|
|
if (lMatches.Count == 1)
|
|
{
|
|
return lMatches[0];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |