Ejemplo n.º 1
0
        public async Task <UsuarioComplemento> GetByUserIdAndTypeComplementAndNameAsync(int usuarioId, TipoComplemento tipoComplemento, string nome)
        {
            const string sql = @"SELECT  
                                        *
                                FROM CPR_USUARIO_COMPLEMENTO  (NOLOCK) UC
                                INNER JOIN CPR_USUARIO (NOLOCK) U ON UC.CPR_USUARIO_ID = U.CPR_USUARIO_ID
                                WHERE UC.CPR_USUARIO_ID = @usuarioId AND UC.TIPO_COMPLEMENTO_ID = @tipoComplemento AND UPPER(UC.NOME) = UPPER(@nome);";

            var p = new { usuarioId, tipoComplemento = tipoComplemento.GetHashCode(), nome = new DbString()
                          {
                              Value = nome, Length = 180, IsAnsi = true
                          } };

            return((await this.Connection.SqlConnection.QueryAsync <UsuarioComplemento, Usuario, UsuarioComplemento>(sql, map:
                                                                                                                     (usuarioComplemento, usuario) =>
            {
                usuarioComplemento.Usuario = usuario;
                return usuarioComplemento;
            }, splitOn: "CPR_USUARIO_ID,CPR_USUARIO_ID", param: p)).FirstOrDefault());
        }
Ejemplo n.º 2
0
 public UsuarioComplementoArquivo(TipoComplemento usuarioTipoComplemento, string nome, string valor)
 {
     UsuarioTipoComplemento = usuarioTipoComplemento;
     Nome  = nome;
     Valor = valor;
 }
Ejemplo n.º 3
0
        public async Task <IEnumerable <UsuarioComplemento> > GetAllByUserIdAndTypeComplementAsync(int usuarioId, TipoComplemento tipoComplemento)
        {
            const string sql = @"SELECT  
                                        *
                                FROM CPR_USUARIO_COMPLEMENTO  (NOLOCK) UC
                                INNER JOIN CPR_USUARIO (NOLOCK) U ON UC.CPR_USUARIO_ID = U.CPR_USUARIO_ID
                                WHERE UC.CPR_USUARIO_ID = @usuarioId AND UC.TIPO_COMPLEMENTO_ID = @tipoComplemento
                                ORDER BY UC.VALOR";

            return(await this.Connection.SqlConnection.QueryAsync <UsuarioComplemento, Usuario, UsuarioComplemento>(sql, map:
                                                                                                                    (usuarioComplemento, usuario) =>
            {
                usuarioComplemento.Usuario = usuario;
                return usuarioComplemento;
            }, splitOn: "CPR_USUARIO_ID,CPR_USUARIO_ID", param: new { usuarioId, tipoComplemento = tipoComplemento.GetHashCode() }));
        }