[英]How do I make sure I receive the whole message if it doesn't fit in the buffer in TCP?
[英]When searching through a sharepoint list how do I make sure it doesn't filter on capital?
我的代码到目前为止:
List<SearchEntity> results = new List<SearchEntity>();
var title = tbTitle.Text;
var adress = tbAdress.Text;
var city = tbCity.Text;
foreach (var item in list.Items.Cast<SPListItem>().Where(r => title.Contains(r.Title) || adress.Contains((string)r["Adress"]) || city.Contains((string)r["City"])))
{
var result = new SearchEntity
{
title = item.Title,
adress = (string)item["Adress"],
city = (string)item["City"],
};
results.Add(result);
}
return results;
我已经尝试了所有的值.ToLower()
和.ToUpper()
但似乎没有做到这一点。
方法String.Contains执行区分大小写和区分大小写的比较,因此如果您想要不区分大小写包含使用IndexOf方法,
title.IndexOf(r.Title, StringComparison.InvariantCultureIgnoreCase) >= 0
但是在你的代码中,你获取所有项目并过滤那里的记录,如果List将包含许多项目,建议不要采用这种方式,因为它涉及从列表中获取所有项目。 也许最好使用CAML Query (或Sharepoint2010中的LINQ )。 你想找到什么? 字段标题/城市/地址包含来自vars标题/城市/地址的值的项目,或者您想要查找字段标题/城市/地址值包含在变量标题/城市/地址中的项目。 在第一种情况下,您的CAML将如下:
List<SearchEntity> results = new List<SearchEntity>();
var title = tbTitle.Text;
var adress = tbAdress.Text;
var city = tbCity.Text;
var query = new SPQuery()
{
Query = string.Format(
@"
<Where>
<Or>
<Or>
<Contains>
<FieldRef Name=""Title"" />
<Value Type=""Text"">{0}</Value>
</Contains>
<Contains>
<FieldRef Name=""Adress"" />
<Value Type=""Text"">{1}</Value>
</Contains>
</Or>
<Contains>
<FieldRef Name=""City"" />
<Value Type=""Text"">{2}</Value>
</Contains>
</Or>
</Where>", title, adress, city)
};
var items = list.GetItems(query);
foreach (var item in items)
{
var result = new SearchEntity
{
title = item.Title,
adress = (string)item["Adress"],
city = (string)item["City"],
};
results.Add(result);
}
return results;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.