예제 #1
0
        /// <summary>
        /// 把DataRow转换成Model
        /// </summary>
        public DBHouseInfo ToModel(DbDataReader dr)
        {
            DBHouseInfo houseInfo = new DBHouseInfo();

            houseInfo.Id                  = (long)ToModelValue(dr, "Id");
            houseInfo.HouseTitle          = (string)ToModelValue(dr, "HouseTitle");
            houseInfo.HouseOnlineURL      = (string)ToModelValue(dr, "HouseOnlineURL");
            houseInfo.HouseLocation       = (string)ToModelValue(dr, "HouseLocation");
            houseInfo.DisPlayPrice        = (string)ToModelValue(dr, "DisPlayPrice");
            houseInfo.PubTime             = (DateTime?)ToModelValue(dr, "PubTime");
            houseInfo.HousePrice          = (decimal?)ToModelValue(dr, "HousePrice");
            houseInfo.LocationCityName    = (string)ToModelValue(dr, "LocationCityName");
            houseInfo.DataCreateTime      = (DateTime?)ToModelValue(dr, "DataCreateTime");
            houseInfo.Source              = (string)ToModelValue(dr, "Source");
            houseInfo.HouseText           = (string)ToModelValue(dr, "HouseText");
            houseInfo.DataChange_LastTime = (DateTime?)ToModelValue(dr, "DataChange_LastTime");
            houseInfo.IsAnalyzed          = (bool)ToModelValue(dr, "IsAnalyzed");
            return(houseInfo);
        }
예제 #2
0
        /// <summary>
        /// 根据传入Model更新数据并返回更新后的Model
        /// </summary>
        public int UpdateHouseInfo(DBHouseInfo dbHouseInfo)
        {
            string sql =
                "UPDATE HouseInfos " +
                "SET " +
                " HouseTitle = @HouseTitle"
                + ", HouseOnlineURL = @HouseOnlineURL"
                + ", HouseLocation = @HouseLocation"
                + ", DisPlayPrice = @DisPlayPrice"
                + ", HousePrice = @HousePrice"
                + ", LocationCityName = @LocationCityName"
                + ", Source = @Source"
                + ", HouseText = @HouseText"
                + ", IsAnalyzed = @IsAnalyzed"
                + ", Status = @Status"

                + " WHERE Id = @Id";

            MySqlParameter[] para = new MySqlParameter[]
            {
                new MySqlParameter()
                {
                    ParameterName = "@Id", Value = dbHouseInfo.Id, DbType = DbType.Int64
                },
                new MySqlParameter()
                {
                    ParameterName = "@HouseTitle", Value = dbHouseInfo.HouseTitle, DbType = DbType.String
                },
                new MySqlParameter()
                {
                    ParameterName = "@HouseOnlineURL", Value = dbHouseInfo.HouseOnlineURL, DbType = DbType.String
                },
                new MySqlParameter()
                {
                    ParameterName = "@HouseLocation", Value = dbHouseInfo.HouseLocation, DbType = DbType.String
                },

                new MySqlParameter()
                {
                    ParameterName = "@DisPlayPrice", Value = dbHouseInfo.DisPlayPrice, DbType = DbType.String
                },
                new MySqlParameter()
                {
                    ParameterName = "@HousePrice", Value = dbHouseInfo.HousePrice, DbType = DbType.Decimal
                },
                new MySqlParameter()
                {
                    ParameterName = "@LocationCityName", Value = dbHouseInfo.LocationCityName, DbType = DbType.String
                },
                new MySqlParameter()
                {
                    ParameterName = "@Source", Value = dbHouseInfo.Source, DbType = DbType.String
                },
                new MySqlParameter()
                {
                    ParameterName = "@HouseText", Value = dbHouseInfo.HouseText, DbType = DbType.String
                },
                new MySqlParameter()
                {
                    ParameterName = "@IsAnalyzed", Value = dbHouseInfo.IsAnalyzed, DbType = DbType.Boolean
                },
                new MySqlParameter()
                {
                    ParameterName = "@Status", Value = dbHouseInfo.Status, DbType = DbType.Int32
                }
            };

            return(MyDBHelper.ExecuteNonQuery(sql, para));
        }