EF4从SQL Server char(1)创建自定义映射到bool ???? [英] EF4 Create custom mapping from SQL Server char(1) to bool ????

查看:126
本文介绍了EF4从SQL Server char(1)创建自定义映射到bool ????的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了大量关于地图的文章。 尝试做一个基本的事情,比如将SQL Char(1)字段映射到C#布尔属性,这真的很常见。 感到惊讶的是,没有更多将SQL数据类型映射到C#类型的示例在这里 

I've read tons of articles on mapping.  Trying to do a basic thing like map a SQL Char(1) field to a C# boolean property, which is really really common.  Surprised there are not more examples of mapping SQL datatypes to C# types up here 

:) 希望这很容易???

:)  Hopefully this is easy ???

 

 

推荐答案

Hi Marty,

Hi Marty,

在这个阶段,这在EF中是不可能的,我们计划在将来为您的模型和CLR对象之间的映射提供一些可扩展性发布(这将支持这种情况)。目前最好的解决方法是添加第二个属性
进行读/写转换。

This isn't possible in EF at this stage, we do plan to provide some extensibility for mapping between your model and CLR objects in a future release (which would support this scenario among others). For the moment the best workaround is to add a second property that does the read/write conversion.

~Rowan


这篇关于EF4从SQL Server char(1)创建自定义映射到bool ????的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆