如何使用linq搜索字符串单词中的值

时间:2017-06-22 01:09:13

标签: c# linq

我有一个搜索文本auther,在我的数据库中有以下列:

true

如何获取名称:

string authers = name,name2,name3;

我使用此查询并且它不起作用???

3 个答案:

答案 0 :(得分:0)

试试这个:

from pap in db.Papers
where pap.Authers.Split(',').Contains(auther)
select pap

答案 1 :(得分:0)

试试这段代码:

    '...
    Dim rngDest As Range
    Set rngDest = Selection '<<starting point for your copying

    '...
    'then inside your loop...

    'copy#1
    wb.Sheets("T & A").Range("D3").Copy           
    rngDest.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, _
                Operation:=xlNone, SkipBlanks:=False,Transpose:=False

    'copy#2 is offset one column over
    wb.Sheets("T & A").Range("F130").Copy
    rngDest.offset(0, 1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, _
                Operation:=xlNone, SkipBlanks:=False,Transpose:=False

     'etc....

答案 2 :(得分:0)

试试这个。

var authArray = authers.Split(',').ToList();
var data = db.Papers.Where(pap => authArray.Contains(pap)).ToList();