private static string GetAreaIds(int begin) { string ids = string.Empty; Context db = new Context(); Show.Models.DictionaryModel parent = db.Dictionarys.Where(p => p.Code == "SY_ZJ").FirstOrDefault(); IQueryable <Show.Models.DictionaryModel> dictionarys = db.Dictionarys.Where(p => p.ParentID == parent.ID).OrderBy(p => p.Sort); //所有的租金范围 int beginD = 0; int endD = 0; foreach (var item in dictionarys) { ConvertDicionary(item.Title, out beginD, out endD); if (endD == 0)//都没有上限,肯定有交集 { ids += "," + item.ID; } if (endD > begin)//结束大于begin参数则有交集 { ids += "," + item.ID; } } if (!string.IsNullOrWhiteSpace(ids)) { ids = ids.Remove(0, 1);//去掉首个',' } return(ids); }
private static string GetAreaIds(int begin, int end) { List <Guid> list = new List <Guid>(); Context db = new Context(); Show.Models.DictionaryModel parent = db.Dictionarys.Where(p => p.Code == "SY_ZJ").FirstOrDefault(); IQueryable <Show.Models.DictionaryModel> dictionarys = db.Dictionarys.Where(p => p.ParentID == parent.ID).OrderBy(p => p.Sort); //所有的租金范围 int beginD = 0; int endD = 0; foreach (var item in dictionarys) { ConvertDicionary(item.Title, out beginD, out endD); if (endD == 0 && end > beginD)//endD=0表示endD没有上限 { if (!list.Contains(item.ID)) { list.Add(item.ID); } } if (endD > begin && end > beginD) { if (!list.Contains(item.ID)) { list.Add(item.ID); } } } string ids = string.Join(",", list); return(ids); }