public List <Folder> GetAllFoldersByAccount(int UserId) { List <Folder> list = null; try { using (FAXPECContext dbcontext = new FAXPECContext()) { using (var oCmd = dbcontext.Database.Connection.CreateCommand()) { //var foldersSenders = dbcontext.FOLDERS_SENDERS.Where(x => x.IDSENDER == UserId).ToList(); //foreach (FOLDERS_SENDERS f in foldersSenders) //{ // List<Folder> a = AutoMapperConfiguration.MapToFolderModel(f); //} string queryFolder = "SELECT FOLDERS.ID, FOLDERS.NOME, TIPO,SYSTEM,IDNOME FROM [FAXPEC].[FAXPEC].[FOLDERS],[FAXPEC].[FAXPEC].[FOLDERS_SENDERS] WHERE IDFOLDER=FOLDERS.ID AND IDSENDER=" + UserId; oCmd.CommandText = queryFolder; oCmd.Connection.Open(); using (DbDataReader r = oCmd.ExecuteReader()) { if (r.HasRows) { list = new List <Folder>(); while (r.Read()) { List <ActiveUp.Net.Common.DeltaExt.Action> la = GetActionsFolder(r, UserId); list.Add(DaoSQLServerDBHelper.MapToFolder(r, la)); } } } oCmd.Connection.Close(); } } } catch (Exception ex) { if (!ex.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException(ex.Message, "ERR_ACC_002", string.Empty, string.Empty, ex.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); err.objectID = UserId.ToString(); log.Error(err); } } return(list); }