void ICriteriaPersister.OnSaving(Criteria criteria) { if (criteria is EmployerSearchCriteria) { _employerPersister.OnSaving(criteria); } else if (criteria is MemberSearchCriteria) { _memberPersister.OnSaving(criteria); } }
public static EntitySet <TCriteriaEntity> MapTo <TCriteriaEntity, TCriteria>(this TCriteria criteria, Guid id, ICriteriaPersister criteriaPersister, bool persistantIsString) where TCriteriaEntity : class, ICriteriaEntity, new() where TCriteria : Criteria { var entities = new EntitySet <TCriteriaEntity>(); criteriaPersister.OnSaving(criteria); // Create the set entity and then attach all items that need to be persisted. foreach (var item in criteria.GetPersistantItems(persistantIsString)) { entities.Add(new TCriteriaEntity { id = id, name = item.Name, value = item.Value }); } criteriaPersister.OnSaved(criteria); return(entities); }