Nic*_*ckG 5 linq petapoco npoco
我注意到 NPoco(或 PetaPoco)的工作方式存在巨大差异,具体取决于您使用 LINQ 时调用的函数。
例如,比较 Fetch() 和 Query(),两者似乎都做同样的事情:
A:Fetch<EntryImage>().Where(t => t.EntryType == type && t.EntryID == entryID);
乙:Query<EntryImage>().Where(t => t.EntryType == type && t.EntryID == entryID);
A返回表中的每一行(10,000+),然后过滤客户端。
B仅返回我期望的一行。
我发现这种行为非常危险——很容易在晚上不注意的情况下编写出性能非常糟糕的代码。这是预期的行为吗?如果这是正常行为,有什么方法可以获取以这种方式工作的方法列表,以便我可以尽可能避免使用它们?
小智 5
这是 NPoco 的预期行为。
根据消息来源:
Fetch返回一个列表。
/// <summary>
/// Fetch all objects of type T from the database using the conventions or configuration on the type T.
/// Caution: This will retrieve ALL objects in the table
/// </summary>
List<T> Fetch<T>();
Run Code Online (Sandbox Code Playgroud)
查询返回IQueryProviderWithInincludes(类似IQueryable)
/// <summary>
/// Entry point for LINQ queries
/// </summary>
IQueryProviderWithIncludes<T> Query<T>();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5488 次 |
| 最近记录: |