实体框架 4.1 - 映射错误架构
因此,我有一个格式错误的架构,由于大量遗留代码依赖项,我现在无法触及它。
假设我有一个表 Test,它有一个声明类型为 int 的 IsValid 列。
我希望 poco 域对象具有 IsValid 作为布尔值的正确意图。当在我的存储库中应用查询时,我希望它在查询中正确解析。
.Where(o => o.IsValid == true)
应该解决:
where isvalid = 1
EntityTypeConfiguration 可以以这种方式映射吗?或者我是否必须创建一个自定义表达式解析器来查找存储库中的特殊情况(我不喜欢这样做)?或者还有另一种方法(无需公开域对象上的多个属性)?
谢谢!
So I have a badly formatted schema that I can't touch right now because of a lot of legacy code dependencies.
Supposed I have a table Test and it has a column IsValid that is declared type int.
I want the poco domain object to have the proper intent of IsValid as a boolean. When a query is applied in my repository, I want it to resolve correctly in the query.
.Where(o => o.IsValid == true)
should resolve to:
where isvalid = 1
Can the EntityTypeConfiguration map in this manner or will do I have to create a custom expression parser to look for special cases in the repository (which I prefer not to do)? Or is there another way (without exposing multiple properties on the domain object)?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建一个查询扩展方法来封装此代码:
You can create a query extension method to encapsulate this code: