我想通過傳遞謂詞作爲參數來獲取一定數量的元素。不過,我收到以下錯誤:將謂詞作爲參數傳遞
Cannot implicitly convert type
System.Collections.Generic.IEnumerable < Students.Entities>
tobool
var names = await Task.Run(() => Repository.GetWithNChildren(e => e.Entities.Take(offset)));
public List<T> GetWithNChildren(Expression<Func<T, bool>> predicate = null)
{
var db = _factory.GetConnectionWithLock();
using (db.Lock())
{
return db.GetAllWithChildren(predicate, true);
}
}
GetAllWithChildren
是在SQLite的類
namespace SQLiteNetExtensions.Extensions
{
public static class ReadOperations
{
public static bool EnableRuntimeAssertions;
public static T FindWithChildren<T>(this SQLiteConnection conn, object pk, bool recursive = false) where T : class;
public static List<T> GetAllWithChildren<T>(this SQLiteConnection conn, Expression<Func<T, bool>> filter = null, bool recursive = false) where T : class;
public static void GetChild<T>(this SQLiteConnection conn, T element, string relationshipProperty, bool recursive = false);
public static void GetChild<T>(this SQLiteConnection conn, T element, Expression<Func<T, object>> propertyExpression, bool recursive = false);
public static void GetChild<T>(this SQLiteConnection conn, T element, PropertyInfo relationshipProperty, bool recursive = false);
public static void GetChildren<T>(this SQLiteConnection conn, T element, bool recursive = false);
public static T GetWithChildren<T>(this SQLiteConnection conn, object pk, bool recursive = false) where T : class;
}
}
哪一行有錯誤 –
第一行有錯誤 – hotspring
顯然,'的IEnumerable'的'。取(返回)'不能被轉換爲「布爾」。什麼是如此令人驚訝? –