如何使用 Sqlite.Net 扩展过滤器
How do I use Sqlite.Net Extensions Filter
我正在使用 Sqlite.Net Extensions 库从我的数据库中获取对象。
我有一个 Id's
的列表,我想从列表中包含该 ID 的数据库中获取所有对象。
我得到了以下信息:
var filteredCalls = listOfIds;
var conn = Databsae.Connection;
var NewCalls = conn.GetAllWithChildren<Call>(x => filteredCalls.Any(y => y == x.Id));
但是这段代码returns错误:
[ERROR] FATAL UNHANDLED EXCEPTION:
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. ---> System.NotSupportedException:
Cannot compile: Lambda 08-30 15:46:57.210 E/mono-rt (16849): at
SQLite.Net.TableQuery1[T].CompileExpr
(System.Linq.Expressions.Expression expr,
System.Collections.Generic.List
1 queryArgs) [0x007aa] in :0 08-30 15:46:57.210 E/mono-rt (16849): at
SQLite.Net.TableQuery1[T].CompileExpr
(System.Linq.Expressions.Expression expr,
System.Collections.Generic.List
1 queryArgs) [0x001a5] in :0 08-30 15:46:57.210 E/mono-rt (16849): at
SQLite.Net.TableQuery1[T].GenerateCommand (System.String
selectionList) [0x0006d] in <filename unknown>:0 08-30 15:46:57.210
E/mono-rt (16849): at SQLite.Net.TableQuery
1[T].GetEnumerator ()
[0x00008] in :0 08-30 15:46:57.210 E/mono-rt
(16849): at System.Collections.Generic.List1[T]..ctor
(IEnumerable
1 collection) [0x00073] in
/Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/collections/generic/list.cs:98
08-30 15:46:57.210 E/mono-rt (16849): at
System.Linq.Enumerable.ToList[TSource] (IEnumerable1 source)
[0x00011] in
/Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:835
08-30 15:46:57.210 E/mono-rt (16849): at
SQLiteNetExtensions.Extensions.ReadOperations.GetAllWithChildren[T]
(SQLite.Net.SQLiteConnection conn,
System.Linq.Expressions.Expression
1 filter, Boolean recursive)
[0x00015] in
/Users/redent/Documents/workspace/sqlite-net-extensions/SQLiteNetExtensions/Extensions/ReadOperations.cs:60
那么我应该如何使用 GetAllWithChildren
方法而不会崩溃?文档非常稀疏
额外
这是line where the method is implemented
可能如所述,Sqlite 不支持 lambda 表达式here如果是这种情况,替代方法是什么/应该如何使用此方法?
所以看起来 Sqlite.Net
无法处理嵌套在另一个 lamdba 表达式中的 Lambda 表达式。因此,我将过滤器更改为:
var NewCalls = conn.GetAllWithChildren<DiaryCall>(x => filteredCalls.Contains(x.Id));
我正在使用 Sqlite.Net Extensions 库从我的数据库中获取对象。
我有一个 Id's
的列表,我想从列表中包含该 ID 的数据库中获取所有对象。
我得到了以下信息:
var filteredCalls = listOfIds;
var conn = Databsae.Connection;
var NewCalls = conn.GetAllWithChildren<Call>(x => filteredCalls.Any(y => y == x.Id));
但是这段代码returns错误:
[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NotSupportedException: Cannot compile: Lambda 08-30 15:46:57.210 E/mono-rt (16849): at SQLite.Net.TableQuery
1[T].CompileExpr (System.Linq.Expressions.Expression expr, System.Collections.Generic.List
1 queryArgs) [0x007aa] in :0 08-30 15:46:57.210 E/mono-rt (16849): at SQLite.Net.TableQuery1[T].CompileExpr (System.Linq.Expressions.Expression expr, System.Collections.Generic.List
1 queryArgs) [0x001a5] in :0 08-30 15:46:57.210 E/mono-rt (16849): at SQLite.Net.TableQuery1[T].GenerateCommand (System.String selectionList) [0x0006d] in <filename unknown>:0 08-30 15:46:57.210 E/mono-rt (16849): at SQLite.Net.TableQuery
1[T].GetEnumerator () [0x00008] in :0 08-30 15:46:57.210 E/mono-rt (16849): at System.Collections.Generic.List1[T]..ctor (IEnumerable
1 collection) [0x00073] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/collections/generic/list.cs:98 08-30 15:46:57.210 E/mono-rt (16849): at System.Linq.Enumerable.ToList[TSource] (IEnumerable1 source) [0x00011] in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:835 08-30 15:46:57.210 E/mono-rt (16849): at SQLiteNetExtensions.Extensions.ReadOperations.GetAllWithChildren[T] (SQLite.Net.SQLiteConnection conn, System.Linq.Expressions.Expression
1 filter, Boolean recursive) [0x00015] in /Users/redent/Documents/workspace/sqlite-net-extensions/SQLiteNetExtensions/Extensions/ReadOperations.cs:60
那么我应该如何使用 GetAllWithChildren
方法而不会崩溃?文档非常稀疏
额外
这是line where the method is implemented
可能如所述,Sqlite 不支持 lambda 表达式here如果是这种情况,替代方法是什么/应该如何使用此方法?
所以看起来 Sqlite.Net
无法处理嵌套在另一个 lamdba 表达式中的 Lambda 表达式。因此,我将过滤器更改为:
var NewCalls = conn.GetAllWithChildren<DiaryCall>(x => filteredCalls.Contains(x.Id));