Esempio n. 1
0
        ///<Summary>
        ///Select all rows by foreign key
        ///This method returns all data rows in the table IdentityUserRole based on a foreign key
        ///</Summary>
        ///<returns>
        ///IList-IDAOIdentityUserRole.
        ///</returns>
        ///<parameters>
        ///Int32? roleId
        ///</parameters>
        public static IList <IDAOIdentityUserRole> SelectAllByRoleId(Int32?roleId)
        {
            Doing(null);
            SqlCommand command = new SqlCommand();

            command.CommandText = InlineProcs.ctprIdentityUserRole_SelectAllByRoleId;
            command.CommandType = CommandType.Text;
            SqlConnection staticConnection = StaticSqlConnection;

            command.Connection = staticConnection;

            DataTable      dt         = new DataTable("IdentityUserRole");
            SqlDataAdapter sqlAdapter = new SqlDataAdapter(command);

            try
            {
                command.Parameters.Add(CtSqlParameter.Get("@RoleId", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)roleId ?? (object)DBNull.Value));

                staticConnection.Open();
                sqlAdapter.Fill(dt);
                Done(null);

                List <IDAOIdentityUserRole> objList = new List <IDAOIdentityUserRole>();
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        DAOIdentityUserRole retObj = new DAOIdentityUserRole();
                        retObj._userId = Convert.IsDBNull(row["UserId"]) ? (Int32?)null : (Int32?)row["UserId"];
                        retObj._roleId = Convert.IsDBNull(row["RoleId"]) ? (Int32?)null : (Int32?)row["RoleId"];
                        objList.Add(retObj);
                    }
                }
                return(objList);
            }
            catch (Exception ex)
            {
                Failed(null, ex);
                Handle(null, ex);
                return(null);
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }
Esempio n. 2
0
        ///<Summary>
        ///Select all rows by filter criteria
        ///This method returns all data rows in the table using criteriaquery api IdentityUserRole
        ///</Summary>
        ///<returns>
        ///IList-IDAOIdentityUserRole.
        ///</returns>
        ///<parameters>
        ///IList<IDataCriterion> listCriterion, IList<IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake
        ///</parameters>
        public static IList <IDAOIdentityUserRole> SelectAllByCriteria(IList <IDataCriterion> listCriterion, IList <IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake)
        {
            Doing(null);
            SqlCommand command = new SqlCommand();

            command.CommandText = GetSelectionCriteria(InlineProcs.ctprIdentityUserRole_SelectAllByCriteria, null, listCriterion, listOrder, dataSkip, dataTake);
            command.CommandType = CommandType.Text;
            SqlConnection staticConnection = StaticSqlConnection;

            command.Connection = staticConnection;

            DataTable      dt         = new DataTable("IdentityUserRole");
            SqlDataAdapter sqlAdapter = new SqlDataAdapter(command);

            try
            {
                staticConnection.Open();
                sqlAdapter.Fill(dt);
                Done(null);

                List <IDAOIdentityUserRole> objList = new List <IDAOIdentityUserRole>();
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        DAOIdentityUserRole retObj = new DAOIdentityUserRole();
                        retObj._userId = Convert.IsDBNull(row["UserId"]) ? (Int32?)null : (Int32?)row["UserId"];
                        retObj._roleId = Convert.IsDBNull(row["RoleId"]) ? (Int32?)null : (Int32?)row["RoleId"];
                        objList.Add(retObj);
                    }
                }
                return(objList);
            }
            catch (Exception ex)
            {
                Failed(null, ex);
                Handle(null, ex);
                return(null);
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }