///<Summary> ///</Summary> ///<returns> ///Int32 ///</returns> ///<parameters> ///DAORole daoRole ///</parameters> public static Int32 SelectAllBySearchFieldsCount(DAORole daoRole) { SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprrole_SelectAllBySearchFieldsCount; command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; try { command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)daoRole.Id ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@name", SqlDbType.VarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)daoRole.Name ?? (object)DBNull.Value)); staticConnection.Open(); Int32 retCount = (Int32)command.ExecuteScalar(); return(retCount); } catch { throw; } finally { staticConnection.Close(); command.Dispose(); } }
///<Summary> ///</Summary> ///<returns> ///IList-DAORole. ///</returns> ///<parameters> ///DAORole daoRole ///</parameters> public static IList <DAORole> SelectAllBySearchFields(DAORole daoRole) { SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprrole_SelectAllBySearchFields; command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("role"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)daoRole.Id ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@name", SqlDbType.VarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)daoRole.Name ?? (object)DBNull.Value)); staticConnection.Open(); sqlAdapter.Fill(dt); List <DAORole> objList = new List <DAORole>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { DAORole retObj = new DAORole(); retObj._id = Convert.IsDBNull(row["id"]) ? (Int32?)null : (Int32?)row["id"]; retObj._name = Convert.IsDBNull(row["name"]) ? null : (string)row["name"]; objList.Add(retObj); } } return(objList); } catch { throw; } finally { staticConnection.Close(); command.Dispose(); } }
///<Summary> ///Select all rows ///This method returns all data rows in the table role ///</Summary> ///<returns> ///IList-DAORole. ///</returns> ///<parameters> /// ///</parameters> public static IList <DAORole> SelectAll() { SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprrole_SelectAll; command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("role"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { staticConnection.Open(); sqlAdapter.Fill(dt); List <DAORole> objList = new List <DAORole>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { DAORole retObj = new DAORole(); retObj._id = Convert.IsDBNull(row["id"]) ? (Int32?)null : (Int32?)row["id"]; retObj._name = Convert.IsDBNull(row["name"]) ? null : (string)row["name"]; objList.Add(retObj); } } return(objList); } catch { throw; } finally { staticConnection.Close(); command.Dispose(); } }
///<Summary> ///Select one row by primary key(s) ///This method returns one row from the table role based on the primary key(s) ///</Summary> ///<returns> ///DAORole ///</returns> ///<parameters> ///Int32? id ///</parameters> public static DAORole SelectOne(Int32?id) { SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprrole_SelectOne; command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("role"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)id ?? (object)DBNull.Value)); staticConnection.Open(); sqlAdapter.Fill(dt); DAORole retObj = null; if (dt.Rows.Count > 0) { retObj = new DAORole(); retObj._id = Convert.IsDBNull(dt.Rows[0]["id"]) ? (Int32?)null : (Int32?)dt.Rows[0]["id"]; retObj._name = Convert.IsDBNull(dt.Rows[0]["name"]) ? null : (string)dt.Rows[0]["name"]; } return(retObj); } catch { throw; } finally { staticConnection.Close(); command.Dispose(); } }