Exemplo n.º 1
0
        public System.Collections.IList FindAll(AppFrame.ObjectCriteria criteria)
        {
            return (IList)HibernateTemplate.Execute(
                delegate(ISession session)
                {
                    //try
                    //{
                        ICriteria hibernateCriteria = session.CreateCriteria(typeof(LoginModel));
                        if (criteria != null)
                        {
                            IDictionary<string, SubObjectCriteria> map = criteria.GetSubCriteria();
                            if (map.Count > 0)
                            {
                                foreach (string key in map.Keys)
                                {
                                    hibernateCriteria.CreateAlias(key, key);
                                }
                                AddCriteriaAndOrder(hibernateCriteria, criteria.GetWhere(), criteria.GetOrder());

                                foreach (string key in map.Keys)
                                {
                                    SubObjectCriteria subCriteria = null;
                                    map.TryGetValue(key, out subCriteria);
                                    AddCriteriaAndOrder(hibernateCriteria, subCriteria.GetWhere(), subCriteria.GetOrder());
                                }
                            }
                            else
                            {
                                AddCriteriaAndOrder(hibernateCriteria, criteria.GetWhere(), criteria.GetOrder());
                            }
                        }
                        return hibernateCriteria.List();
                    //}
                    //catch (Exception)
                    //{
                    //    return null;
                    //}

                }
                );
        }