Esempio n. 1
0
 public async Task <IEnumerable <TOut> > QueryTypedStoredProcedure <TPassing, TOut>(string SPName, TPassing Object)
     where TPassing : class
     where TOut : class
 {
     try
     {
         var xmlperson = ObjectXMLPurser.ObjectToXMLGeneric <TPassing>(Object);
         using (IDbConnection db = new SqlConnection(_Conn._ConnectionString))
         {
             DynamicParameters parameter = new DynamicParameters();
             parameter.Add("@XMLSQL", xmlperson, DbType.String, ParameterDirection.Input);
             parameter.Add("@Status", dbType: DbType.Int32, direction: ParameterDirection.Output);
             return(await db.QueryAsync <TOut>(SPName, parameter, commandType : CommandType.StoredProcedure));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
        public async Task <int> ExcuteStoredProcedureToSave <T>(string SPName, T Object) where T : class
        {
            try
            {
                var xmlperson = ObjectXMLPurser.ObjectToXMLGeneric <T>(Object);
                using (IDbConnection db = new SqlConnection(_Conn._ConnectionString))
                {
                    DynamicParameters parameter = new DynamicParameters();
                    parameter.Add("@XMLSQL", xmlperson, DbType.String, ParameterDirection.Input);
                    parameter.Add("@Status", dbType: DbType.Int32, direction: ParameterDirection.Output);
                    await db.ExecuteAsync(SPName, parameter, commandType : CommandType.StoredProcedure);

                    int rowCount = parameter.Get <int>("@Status");
                    return(rowCount);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }