///<Summary> ///Select all rows by filter criteria ///This method returns all data rows in the table using criteriaquery api Region ///</Summary> ///<returns> ///IList-IDAORegion. ///</returns> ///<parameters> ///IList<IDataCriterion> listCriterion, IList<IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake ///</parameters> public static IList <IDAORegion> SelectAllByCriteria(IList <IDataCriterion> listCriterion, IList <IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake) { Doing(null); SqlCommand command = new SqlCommand(); command.CommandText = GetSelectionCriteria(InlineProcs.ctprRegion_SelectAllByCriteria, null, listCriterion, listOrder, dataSkip, dataTake); command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("Region"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { staticConnection.Open(); sqlAdapter.Fill(dt); Done(null); List <IDAORegion> objList = new List <IDAORegion>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { DAORegion retObj = new DAORegion(); retObj._regionID = Convert.IsDBNull(row["RegionID"]) ? (Int32?)null : (Int32?)row["RegionID"]; retObj._regionDescription = Convert.IsDBNull(row["RegionDescription"]) ? null : (string)row["RegionDescription"]; retObj._ctrVersion = Convert.IsDBNull(row["ctr_version"]) ? (Int32?)null : (Int32?)row["ctr_version"]; objList.Add(retObj); } } return(objList); } catch (Exception ex) { Failed(null, ex); Handle(null, ex); return(null); } finally { staticConnection.Close(); command.Dispose(); } }
///<Summary> ///Select one row by primary key(s) ///This method returns one row from the table Region based on the primary key(s) ///</Summary> ///<returns> ///IDAORegion ///</returns> ///<parameters> ///Int32? regionID ///</parameters> public static IDAORegion SelectOne(Int32?regionID) { Doing(null); SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprRegion_SelectOne; command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("Region"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { command.Parameters.Add(CtSqlParameter.Get("@RegionID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)regionID ?? (object)DBNull.Value)); staticConnection.Open(); sqlAdapter.Fill(dt); Done(null); DAORegion retObj = null; if (dt.Rows.Count > 0) { retObj = new DAORegion(); retObj._regionID = Convert.IsDBNull(dt.Rows[0]["RegionID"]) ? (Int32?)null : (Int32?)dt.Rows[0]["RegionID"]; retObj._regionDescription = Convert.IsDBNull(dt.Rows[0]["RegionDescription"]) ? null : (string)dt.Rows[0]["RegionDescription"]; retObj._ctrVersion = Convert.IsDBNull(dt.Rows[0]["ctr_version"]) ? (Int32?)null : (Int32?)dt.Rows[0]["ctr_version"]; } return(retObj); } catch (Exception ex) { Failed(null, ex); Handle(null, ex); return(null); } finally { staticConnection.Close(); command.Dispose(); } }