Exemplo n.º 1
0
        public async Task <List <UseRelated> > GetRelatedUsersByUserId(int id)
        {
            var result = from UR in _dbContext.UseRelateds
                         join U in _dbContext.Users on UR.RelatedUserId equals U.Id
                         join C in _dbContext.Cities on U.CityId equals C.Id
                         join CT in (from CTL in _dbContext.City_Translations
                                     join L in _dbContext.Languages on CTL.LanguageId equals L.Id
                                     where L.Code == langCode
                                     select new { CTL }) on U.CityId equals CT.CTL.CityId into C_CT
                         from CT in C_CT.DefaultIfEmpty()

                         where UR.UserId == id
                         select new UseRelated(UR, U, C, CT.CTL, id);

            return(await result.ToListAsync());
        }
Exemplo n.º 2
0
        public async Task <User> GetUser(int id)
        {
            var result = from U in _dbContext.Users
                         join C in _dbContext.Cities on U.CityId equals C.Id
                         join CT in (from CTL in _dbContext.City_Translations
                                     join L in _dbContext.Languages on CTL.LanguageId equals L.Id
                                     where L.Code == langCode
                                     select new { CTL }) on U.CityId equals CT.CTL.CityId into C_CT
                         from CT in C_CT.DefaultIfEmpty()

                         /*join UI in _dbContext.UserImages on U.Id equals UI.UserId into U_UI
                          * from UI in U_UI.DefaultIfEmpty()
                          * join UR in _dbContext.UseRelateds on U.Id equals UR.UserId into U_UR
                          * from UR in U_UR.DefaultIfEmpty()*/
                         where U.Id == id
                         select new User(U, C, CT.CTL);

            return(await result.FirstOrDefaultAsync());
        }