示例#1
0
        public static async Task <List <Customer> > FetchUsersByFilter(CustomerFilter filter)
        {
            LomoUsersEntities dbContext = new LomoUsersEntities();
            var query = from u in dbContext.Users
                        join ulTmp in dbContext.UsersLocations on u.Id equals ulTmp.UserId into userLocations
                        from ul in userLocations.DefaultIfEmpty()
                        select new Customer
            {
                GlobalId    = u.Id,
                Name        = u.Name,
                Email       = u.Email,
                MSID        = u.MsId,
                PhoneNumber = u.PhoneNumber,
                State       = ul != null ? ul.State : string.Empty,
                City        = ul != null ? ul.City : string.Empty,
                ZipCode     = ul != null ? ul.ZipCode : string.Empty
            };

            if (!string.IsNullOrWhiteSpace(filter.Email))
            {
                query = query.Where(x => x.Email == filter.Email);
            }

            if (filter.UserId != null)
            {
                query = query.Where(x => x.GlobalId == filter.UserId);
            }

            if (!string.IsNullOrWhiteSpace(filter.MSIDorPUID))
            {
                query = query.Where(x => x.MSID == filter.MSIDorPUID);
            }

            return(await query.ToListAsync());
        }
示例#2
0
        public static async Task <List <Customer> > FetchUsersByIds(List <Guid> ids)
        {
            LomoUsersEntities dbContext = new LomoUsersEntities();
            var query = from u in dbContext.Users
                        join ulTmp in dbContext.UsersLocations on u.Id equals ulTmp.UserId into userLocations
                        from ul in userLocations.DefaultIfEmpty()
                        where ids.Contains(u.Id)
                        select new Customer
            {
                GlobalId    = u.Id,
                Name        = u.Name,
                Email       = u.Email,
                MSID        = u.MsId,
                PhoneNumber = u.PhoneNumber,
                State       = ul != null ? ul.State : string.Empty,
                City        = ul != null ? ul.City : string.Empty,
                ZipCode     = ul != null ? ul.ZipCode : string.Empty
            };

            return(await query.ToListAsync());
        }