예제 #1
0
        public List <LookUP> GetAllPropertyTypes()
        {
            List <LookUP> list = new List <LookUP>();
            SqlConnection con  = new SqlConnection();

            con.ConnectionString = _conStr;
            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = con;
                cmd.CommandText = "SELECT * FROM PropertyType";
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        LookUP propertyType = new LookUP();
                        propertyType.Id   = rdr["Id"] != DBNull.Value ? (int)rdr["Id"] : -1;
                        propertyType.Name = rdr["PropertyType"] != DBNull.Value ? (string)rdr["PropertyType"] : string.Empty;

                        list.Add(propertyType);
                    }
                }
            }
            catch (Exception ex)
            {
                list = null;
            }
            finally
            {
                con.Close();
            }
            return(list);
        }
        public static LookUPModel TranslateLookUpModel(this LookUP from)
        {
            LookUPModel to = new LookUPModel();

            to.Id   = from.Id;
            to.Name = from.Name;

            return(to);
        }