Exemplo n.º 1
0
        public IList <ILsoIGroup> GetAllWithDataLike(int uid, string groupName, string groupDescr)
        {
            if (!String.IsNullOrEmpty(groupName) && !String.IsNullOrEmpty(groupDescr))
            {
                IQueryable <IGroup> groups = null;
                if (uid > 0)
                {
                    groups = (from p in _Db.IGroups
                              where uid == p.UID &&
                              (System.Data.Linq.SqlClient.SqlMethods.Like(p.GroupName, DbUtils.ConvertToSqlLike(groupName)) ||
                               System.Data.Linq.SqlClient.SqlMethods.Like(p.GroupDescr, DbUtils.ConvertToSqlLike(groupDescr)))
                              select p).Take(1000);
                }
                else
                {
                    groups = (from p in _Db.IGroups
                              where System.Data.Linq.SqlClient.SqlMethods.Like(p.GroupName, DbUtils.ConvertToSqlLike(groupName)) ||
                              System.Data.Linq.SqlClient.SqlMethods.Like(p.GroupDescr, DbUtils.ConvertToSqlLike(groupDescr))
                              select p).Take(1000);
                }

                var converter = new LsoIGroupFactory();
                return(groups.Select(group => converter.Create(group)).ToList());
            }
            return(new List <ILsoIGroup>());
        }
Exemplo n.º 2
0
        public IList <ILsoIGroup> GetAllForUID(int uid)
        {
            // it appears executequery only returns IEnumerable, so working with a list at each point
            // where we check results, results should be limited to 1 row, so not a big waste of
            // resources to do this
            IEnumerable <IGroup> igroups = from g in _Db.IGroups
                                           where g.UID == uid
                                           select g;
            var igroupsList = igroups.ToList();


            if (igroupsList.Count() > 0)
            {
                var converter = new LsoIGroupFactory();
                var domigroup = converter.Create(igroupsList.First());
                var actigroup = (LsoIGroup)domigroup;
                var retval    = new List <ILsoIGroup>();
                retval.Add(actigroup);
                return(retval);
            }

            return(new List <ILsoIGroup>());
        }