Hey folks,
I have a collection of entities that all inherit from PolicyEntity. I'd like to get only the entities of a specific type. I thought using the collection FindMatches method with GetEntityTypeFilter would work but it doesn't. I just get a list of indexes... ALL the indexes.
I my working scenario there are 3 entities in the collection all of a different type but all inheriting from PolicyEntity. The result I was expecting was for a list of indexes with just one entry not three.
Is there a way to get only the entities of type X from a collection?
public override void Save(QuoteEntity quote)
{
PolicyNegligenceEntity neg = null;
List<int> indexes = quote.Policy.FindMatches(PolicyNegligenceEntity.GetEntityTypeFilter());
if (indexes.Count > 0)
neg = quote.Policy[indexes[0]] as PolicyNegligenceEntity;
if (neg == null)
quote.Policy.Add(neg = new PolicyNegligenceEntity());
neg.PolicyStartDate = PolicyStartDate.SelectedValue.Value;
neg.BusinessPostcode = BusinessPostcode.Text;
}
So in the above example the neg == null check always passes because the object is not PolicyNegligenceEntity...
I've found a post claiming this approach works but I must be missing something...
http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=10627
(llbl 2.0/adapter/.net 2.0)