public int GetContactCardsCount(IContactsExp exp) { var query = new SqlQuery(ContactsTable.TABLE_NAME.Alias(MAIL_CONTACTS)) .SelectCount("distinct " + ContactsTable.Columns.Id.Prefix(MAIL_CONTACTS)) .LeftOuterJoin(ContactInfoTable.TABLE_NAME.Alias(CONTACT_INFO), Exp.EqColumns(ContactsTable.Columns.Id.Prefix(MAIL_CONTACTS), ContactInfoTable.Columns.ContactId.Prefix(CONTACT_INFO))) .Where(exp.GetExpression()); var result = Db.ExecuteScalar <int>(query); return(result); }
public List <ContactCard> GetContactCards(IContactsExp exp) { var query = new SqlQuery(ContactsTable.TABLE_NAME.Alias(MAIL_CONTACTS)) .Select(ContactsTable.Columns.Id.Prefix(MAIL_CONTACTS), ContactsTable.Columns.User.Prefix(MAIL_CONTACTS), ContactsTable.Columns.Tenant.Prefix(MAIL_CONTACTS), ContactsTable.Columns.ContactName.Prefix(MAIL_CONTACTS), ContactsTable.Columns.Address.Prefix(MAIL_CONTACTS), ContactsTable.Columns.Description.Prefix(MAIL_CONTACTS), ContactsTable.Columns.Type.Prefix(MAIL_CONTACTS), ContactsTable.Columns.HasPhoto.Prefix(MAIL_CONTACTS)) .Where(exp.GetExpression()); if (exp.OrderAsc.HasValue) { query.OrderBy(ContactsTable.Columns.ContactName.Prefix(MAIL_CONTACTS), exp.OrderAsc.HasValue); } if (exp.StartIndex.HasValue) { query.SetFirstResult(exp.StartIndex.Value); } if (exp.Limit.HasValue) { query.SetMaxResults(exp.Limit.Value); } var contacts = Db.ExecuteList(query) .ConvertAll(ToContact); var ids = contacts.Select(c => c.Id).ToList(); query = new SqlQuery(ContactInfoTable.TABLE_NAME.Alias(CONTACT_INFO)) .Select(ContactInfoTable.Columns.Id.Prefix(CONTACT_INFO), ContactInfoTable.Columns.Tenant.Prefix(CONTACT_INFO), ContactInfoTable.Columns.User.Prefix(CONTACT_INFO), ContactInfoTable.Columns.ContactId.Prefix(CONTACT_INFO), ContactInfoTable.Columns.Data.Prefix(CONTACT_INFO), ContactInfoTable.Columns.Type.Prefix(CONTACT_INFO), ContactInfoTable.Columns.IsPrimary.Prefix(CONTACT_INFO)) .Where(Exp.In(ContactInfoTable.Columns.ContactId.Prefix(CONTACT_INFO), ids)); var contactInfos = Db.ExecuteList(query) .ConvertAll(ToContactInfo); return(ToContactCardList(contacts, contactInfos)); }
public int GetContactCardsCount(IContactsExp exp) { if (exp == null) { throw new ArgumentNullException("exp"); } using (var daoFactory = new DaoFactory()) { var daoContacts = daoFactory.CreateContactCardDao(Tenant, User); var count = daoContacts.GetContactCardsCount(exp); return(count); } }
public List <ContactCard> GetContactCards(IContactsExp exp) { if (exp == null) { throw new ArgumentNullException("exp"); } using (var daoFactory = new DaoFactory()) { var daoContacts = daoFactory.CreateContactCardDao(Tenant, User); var list = daoContacts.GetContactCards(exp); return(list); } }