public IEnumerable <BaseHouseInfo> SearchHouses(HouseSearchCondition condition) { if (string.IsNullOrEmpty(condition.Source)) { var houseList = new List <BaseHouseInfo>(); // 因为会走几个表,默认每个表取N条 var houseSources = GetCityHouseSources(condition.CityName); var limitCount = condition.HouseCount / houseSources.Count; foreach (var houseSource in houseSources) { //建荣家园数据质量比较差,默认不出 if (houseSource == ConstConfigName.CCBHouse) { continue; } condition.Source = houseSource; condition.HouseCount = limitCount; houseList.AddRange(Search(condition)); } return(houseList.OrderByDescending(h => h.PubTime)); } else { return(Search(condition)); } }
public IEnumerable <BaseHouseInfo> Search(HouseSearchCondition condition) { string redisKey = condition.RedisKey; var houses = new List <BaseHouseInfo>(); if (!condition.Refresh) { houses = redis.ReadSearchCache(redisKey); if (houses != null && houses.Count > 0) { return(houses); } } using (IDbConnection dbConnection = GetConnection()) { dbConnection.Open(); houses = dbConnection.Query <BaseHouseInfo>(condition.QueryText, condition).ToList(); if (houses != null && houses.Count > 0) { redis.WriteSearchCache(redisKey, houses); } return(houses); } }