使用sqlite的linq:
var reachTable=db.TableName.where(p=>p.StrField.indexof("123")>=0);
这样失败,但是使用contains成功:
var reachTable=db.TableName.where(p=>p.StrField.contains("123");
难道linq to Sqlite不能使用indexof?
...全文
24610打赏收藏
Linq to Sqlite 的indexof
使用sqlite的linq: var reachTable=db.TableName.where(p=>p.StrField.indexof("123")>=0); 这样失败,但是使用contains成功: var reachTable=db.TableName.where(p=>p.StrField.contains("123"); 难道linq to Sqlite不能使用indexof?
LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, Int32)' method, and this method cannot be translated into a store expression.
You can't use .NET functions in LINQ to Entities its because of security, e.g. IndexOf() may do lot of other things than just checking the string.
Linq to Sql在SqlServer上当然支持indexof的。而且在sqlite的linq里面直接就有indoxof的提示9种参数调用方式:
var reachTable = db.TpRoperty.Where(p=>p.Link==link&&p.Value.Contains(inputText));
var reachTable1 = db.TpRoperty.Where(p => p.Link == link && p.Value.IndexOf(inputText)>=0);