public class ContactManager : ReFlex.Data.ManagerBase<Contact>
{
public List<Contact> GetJohnSmiths(string companyName)
{
if (string.IsNullOrEmpty(companyName))
throw new ArgumentNullException("companyName");
Relationship currentCompanyRelationship = new Relationship(typeof(Company), typeof(Contact), "CurrentCompany", RelationshipTypeEnum.StrongParent);
ConcatenatedFieldList nameList = new ConcatenatedFieldList()
nameList.Add(new TextAffixField(new Field<Contact>("FirstName"), null, " "));
nameList.Add(new Field<Contact>("LastName"));
Criterion<Contact> criterion = new Criterion<Contact>(CriteriaOperatorEnum.And)
.Add(nameList, "John Smith", ComparisonOperatorEnum.Like, CriteriaOperatorEnum.And)
.Add(new Field<Company>("CompanyName", "CurrentCompany"), companyName, ComparisonOperatorEnum.Equals, CriteriaOperatorEnum.And);
Ordering ordering = new Ordering()
.Add<Contact>("LastName", Direction.Ascending)
.Add<Contact>("FirstName", Direction.Ascending);
List<Contact> contacts;
using (ObjectFactory<Contact> mapper = new ObjectFactory<Contact>())
contacts = mapper.GetDataObjects(criterion, ordering, currentCompanyRelationship);
return contacts;
}
}