EF核心:TohashSetAsync()
我已经注意到Microsoft.entityFrameworkCore Linq扩展方法剂量不含Tohashset async 版本,我假设正确&确保物体实现对象的安全方法是标签,因为它可以防止重复,我错过了什么?如果如此重要,为什么它没有异步版本?
I have noticed that Microsoft.EntityFrameworkCore Linq extension methods dose not contain ToHashSet Async version, I'm assuming the right & safe way to materialize the object is HashSet since it protects against duplication, did I missed something? if it's so important why there is no Async version of it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在代码中,您的表被表示为iListsource的DBSET。
Ilistsource有一种方法:
因此,从EntityFrameWorkCore返回的所有内容都是Ilist;一个可索引的,非唯一的价值袋。尽管访问速度要快得多,但它是一个独特的,非索引的价值袋。平等比较决定了它的独特性,而几个列的一切都开始变得非常昂贵。
虽然您可能会认为直接进入标签会更具性能,但如果您需要的话,数据已经是列表。 TolistAsync()只是将玫瑰称为玫瑰,并加载数据。然后,您可以在需要时标记它。
In code, your tables are represented as a DbSet which is an IListSource.
IListSource has one method:
So everything that's returned from EntityFrameworkCore is an IList; an indexable, non-unique bag of values. Whereas a HashSet, being much faster to access, is a unique, non-indexed bag of values. Equality Comparison determines its uniqueness, and anything more than a few columns starts to get really expensive to calculate.
Whilst you might think it'd be more performant to go straight to a HashSet, if that's what you need, the data is already a List. ToListAsync() just calls a rose a rose, and loads the data. Then you can HashSet it if needed.