我想在我的win表单应用程序中进行全文搜索。
public static IEnumerable<DataRow> GetPartDataForFullTextSearch(string text1)
{
using (cEntity context = new cEntity())
{
var query = (
from i in context.tblparts
join s in context.tblpartstatus on i.partstatus
equals s.id
join l in context.tblwarehouse on i.partId
equals l.partId
join p in context.tblwarehouseplace on l.warehouseId
equals p.WhId
orderby i.partID
select new Part
{
PartNumber = i.partID,
PartName = i.partName,
OldPartNo = i.partIdOld,
Comment = i.comment,
Hbv = (long)i.HBVNr,
Status = (int)i.partstatus,
Building = p.building,
Room = p.room,
Shelf = p.shelf,
CaseOfPart = p.case
}).Distinct() as IEnumerable<DataRow>;
var results =
from matchingItem in query
where Regex.IsMatch(matchingItem.Field<string>("partName"), text1)
select matchingItem;
var list = results.ToList();
return list;
}
}
但我没有收到结果=&gt; ArgumentNullException
这就是我想要收到结果的方式
private void tbOverviewFullSearch_TextChanged(object sender, EventArgs e)
{
dgPartOverview.DataSource =
DatabaseQueries.D_PartManagement
.GetPartDataForFullTextSearch(tbOverviewFullSearch.Text);
}
怎么了? 是否可以过滤多个字段?
答案 0 :(得分:2)
您无法将IQueryable<Part>
投射到IEnumerable<DataRow>
。删除演员并执行
Regex.IsMatch(matchingItem.partName), text1)