是否可以在 Linq 属性映射中设置默认排序依据?
我可以在 Active Record 中执行此操作,但这对于 Linq to SQL 可行吗?
I it was possible to do this in Active Record, but is this feasible with Linq to SQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您始终可以向分部类文件中的数据上下文/实体对象添加属性:
然后从 FoosByName 启动的任何查询都将被预先排序(但仍然可组合)。
You can always add a property to the data-context / entities objects in a partial class file:
Then any queries started from
FoosByName
will be pre-ordered (but still composable).如果您使用存储过程或视图来检索数据,则可以。 然后,ORDER BY 可以位于存储过程或视图中,但 LINQ to SQL 不支持开箱即用。
You can if you use stored procedures or views to retrieve your data. The ORDER BY can then be in the stored proc or view but LINQ to SQL doesn't support this out of the box.