我有串的名单像这样搜索对象列表使用LINQ内字符串SQL
List<string> list1 = new List<string>();
例如我的名单是
{one , two , three , four , five}
在数据库中,我有一个string
这样
"five-six-seven-eight"
如何使用Linq to SQL在我的数据库字符串和我的列表之间进行搜索。例如,我的查询搜索应该是真实的,因为“five”在两者上都是常见的。 我的查询是这样的:
var q = from p in m.ViewAbuseReports where
(list1.Contains(p.Abuse.ToString().Split('-')) || list1.Count == 0)
select new
{
Col2 = p.FirstName + " " + p.LastName,
Col3 = p.DateTakhalof,
Col4 = p.DateReturn
};
我没有得到这个问题,你是否善意地更多一些clarrify。 – Ovis
似乎你需要LINQ'Intersect' – Ian
@Ovis我想在字符串中搜索字符串列表,我的字符串在数据库中分割为“ - ” – mosyflasher